Repository navigation
Expand file tree
/
Copy pathBloomAux.cs
More file actions
64 lines (55 loc) · 1.68 KB
/
Copy pathBloomAux.cs
File metadata and controls
64 lines (55 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using NRedisStack.Bloom.Literals;
using StackExchange.Redis;
namespace NRedisStack;
public static class BloomAux
{
public static List<object> BuildInsertArgs(RedisKey key, IEnumerable<RedisValue> items, int? capacity,
double? error, int? expansion, bool nocreate, bool nonscaling)
{
var args = new List<object> { key };
args.AddCapacity(capacity);
args.AddError(error);
args.AddExpansion(expansion);
args.AddNoCreate(nocreate);
args.AddNoScaling(nonscaling);
args.AddItems(items);
return args;
}
private static void AddItems(this List<object> args, IEnumerable<RedisValue> items)
{
args.Add(BloomArgs.ITEMS);
args.AddRange(items.Cast<object>());
}
private static void AddNoScaling(this ICollection<object> args, bool nonScaling)
{
if (nonScaling)
{
args.Add(BloomArgs.NONSCALING);
}
}
private static void AddNoCreate(this ICollection<object> args, bool nocreate)
{
if (nocreate)
{
args.Add(BloomArgs.NOCREATE);
}
}
private static void AddExpansion(this ICollection<object> args, int? expansion)
{
if (expansion == null) return;
args.Add(BloomArgs.EXPANSION);
args.Add(expansion);
}
private static void AddError(this ICollection<object> args, double? error)
{
if (error == null) return;
args.Add(BloomArgs.ERROR);
args.Add(error);
}
private static void AddCapacity(this ICollection<object> args, int? capacity)
{
if (capacity == null) return;
args.Add(BloomArgs.CAPACITY);
args.Add(capacity);
}
}