Skip to content

Commit 9ffc212

Browse files
authored
Pipeline support (#50)
* add pipeline class & test * Update StackExchange version to 2.6.86 * Fix Pipeline test * fix conflicts * support pipelines with batch * Update JsonTests.cs * mark pipline test in comment * fix pipline test * make JsonCommandBuilder static * split bloom commands to sync and async * chagne to public static * split cms to async and sync * separate CF * split graph * split search * split Tdigest * split TS * split TopK * Add commands instance for each module in pipeline class * Add pipeline test for BF * create separate test class for pipeline
1 parent 7e92eb3 commit 9ffc212

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2885
-2363
lines changed

src/NRedisStack/Auxiliary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static RedisResult Execute(this IDatabase db, SerializedCommand command)
3131
return db.Execute(command.Command, command.Args);
3232
}
3333

34-
public async static Task<RedisResult> ExecuteAsync(this IDatabase db, SerializedCommand command)
34+
public async static Task<RedisResult> ExecuteAsync(this IDatabaseAsync db, SerializedCommand command)
3535
{
3636
return await db.ExecuteAsync(command.Command, command.Args);
3737
}

src/NRedisStack/Bloom/BloomCommands.cs

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
namespace NRedisStack
44
{
55

6-
public class BloomCommands : IBloomCommands
6+
public class BloomCommands : BloomCommandsAsync, IBloomCommands
77
{
88
IDatabase _db;
9-
public BloomCommands(IDatabase db)
9+
public BloomCommands(IDatabase db) : base(db)
1010
{
1111
_db = db;
1212
}
@@ -17,49 +17,24 @@ public bool Add(RedisKey key, RedisValue item)
1717
return _db.Execute(BloomCommandBuilder.Add(key, item)).ToString() == "1";
1818
}
1919

20-
/// <inheritdoc/>
21-
public async Task<bool> AddAsync(RedisKey key, RedisValue item)
22-
{
23-
return (await _db.ExecuteAsync(BloomCommandBuilder.Add(key, item))).ToString() == "1";
24-
}
25-
2620
/// <inheritdoc/>
2721
public long Card(RedisKey key)
2822
{
2923
return _db.Execute(BloomCommandBuilder.Card(key)).ToLong();
3024
}
3125

32-
/// <inheritdoc/>
33-
public async Task<long> CardAsync(RedisKey key)
34-
{
35-
return (await _db.ExecuteAsync(BloomCommandBuilder.Card(key))).ToLong();
36-
}
37-
3826
/// <inheritdoc/>
3927
public bool Exists(RedisKey key, RedisValue item)
4028
{
4129
return _db.Execute(BloomCommandBuilder.Exists(key, item)).ToString() == "1";
4230
}
4331

44-
/// <inheritdoc/>
45-
public async Task<bool> ExistsAsync(RedisKey key, RedisValue item)
46-
{
47-
return (await _db.ExecuteAsync(BloomCommandBuilder.Exists(key, item))).ToString() == "1";
48-
}
49-
5032
/// <inheritdoc/>
5133
public BloomInformation Info(RedisKey key)
5234
{
5335
return _db.Execute(BloomCommandBuilder.Info(key)).ToBloomInfo();
5436
}
5537

56-
/// <inheritdoc/>
57-
public async Task<BloomInformation> InfoAsync(RedisKey key)
58-
{
59-
var info = (await _db.ExecuteAsync(BloomCommandBuilder.Info(key)));
60-
return info.ToBloomInfo();
61-
}
62-
6338
/// <inheritdoc/>
6439
public bool[] Insert(RedisKey key, RedisValue[] items, int? capacity = null,
6540
double? error = null, int? expansion = null,
@@ -68,74 +43,35 @@ public bool[] Insert(RedisKey key, RedisValue[] items, int? capacity = null,
6843
return _db.Execute(BloomCommandBuilder.Insert(key, items, capacity, error, expansion, nocreate, nonscaling)).ToBooleanArray();
6944
}
7045

71-
/// <inheritdoc/>
72-
public async Task<bool[]> InsertAsync(RedisKey key, RedisValue[] items, int? capacity = null,
73-
double? error = null, int? expansion = null,
74-
bool nocreate = false, bool nonscaling = false)
75-
{
76-
return (await _db.ExecuteAsync(BloomCommandBuilder.Insert(key, items, capacity, error, expansion, nocreate, nonscaling))).ToBooleanArray();
77-
}
78-
7946
/// <inheritdoc/>
8047
public bool LoadChunk(RedisKey key, long iterator, Byte[] data)
8148
{
8249
return _db.Execute(BloomCommandBuilder.LoadChunk(key, iterator, data)).OKtoBoolean();
8350
}
8451

85-
/// <inheritdoc/>
86-
public async Task<bool> LoadChunkAsync(RedisKey key, long iterator, Byte[] data)
87-
{
88-
return (await _db.ExecuteAsync(BloomCommandBuilder.LoadChunk(key, iterator, data))).OKtoBoolean();
89-
}
90-
9152
/// <inheritdoc/>
9253
public bool[] MAdd(RedisKey key, params RedisValue[] items)
9354
{
9455
return _db.Execute(BloomCommandBuilder.MAdd(key, items)).ToBooleanArray();
9556
}
9657

97-
/// <inheritdoc/>
98-
public async Task<bool[]> MAddAsync(RedisKey key, params RedisValue[] items)
99-
{
100-
return (await _db.ExecuteAsync(BloomCommandBuilder.MAdd(key, items))).ToBooleanArray();
101-
}
102-
10358
/// <inheritdoc/>
10459
public bool[] MExists(RedisKey key, RedisValue[] items)
10560
{
10661
return _db.Execute(BloomCommandBuilder.MExists(key, items)).ToBooleanArray();
10762
}
10863

109-
/// <inheritdoc/>
110-
public async Task<bool[]> MExistsAsync(RedisKey key, RedisValue[] items)
111-
{
112-
return (await _db.ExecuteAsync(BloomCommandBuilder.MExists(key, items))).ToBooleanArray();
113-
}
114-
11564
/// <inheritdoc/>
11665
public bool Reserve(RedisKey key, double errorRate, long capacity,
11766
int? expansion = null, bool nonscaling = false)
11867
{
11968
return _db.Execute(BloomCommandBuilder.Reserve(key, errorRate, capacity, expansion, nonscaling)).OKtoBoolean();
12069
}
12170

122-
/// <inheritdoc/>
123-
public async Task<bool> ReserveAsync(RedisKey key, double errorRate, long capacity,
124-
int? expansion = null, bool nonscaling = false)
125-
{
126-
return (await _db.ExecuteAsync(BloomCommandBuilder.Reserve(key, errorRate, capacity, expansion, nonscaling))).OKtoBoolean();
127-
}
128-
12971
/// <inheritdoc/>
13072
public Tuple<long, Byte[]> ScanDump(RedisKey key, long iterator)
13173
{
13274
return _db.Execute(BloomCommandBuilder.ScanDump(key, iterator)).ToScanDumpTuple();
13375
}
134-
135-
/// <inheritdoc/>
136-
public async Task<Tuple<long, Byte[]>> ScanDumpAsync(RedisKey key, long iterator)
137-
{
138-
return (await _db.ExecuteAsync(BloomCommandBuilder.ScanDump(key, iterator))).ToScanDumpTuple();
139-
}
14076
}
14177
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using NRedisStack.Bloom.DataTypes;
2+
using StackExchange.Redis;
3+
namespace NRedisStack
4+
{
5+
6+
public class BloomCommandsAsync : IBloomCommandsAsync
7+
{
8+
IDatabaseAsync _db;
9+
public BloomCommandsAsync(IDatabaseAsync db)
10+
{
11+
_db = db;
12+
}
13+
14+
/// <inheritdoc/>
15+
public async Task<bool> AddAsync(RedisKey key, RedisValue item)
16+
{
17+
return (await _db.ExecuteAsync(BloomCommandBuilder.Add(key, item))).ToString() == "1";
18+
}
19+
20+
21+
/// <inheritdoc/>
22+
public async Task<long> CardAsync(RedisKey key)
23+
{
24+
return (await _db.ExecuteAsync(BloomCommandBuilder.Card(key))).ToLong();
25+
}
26+
27+
/// <inheritdoc/>
28+
public async Task<bool> ExistsAsync(RedisKey key, RedisValue item)
29+
{
30+
return (await _db.ExecuteAsync(BloomCommandBuilder.Exists(key, item))).ToString() == "1";
31+
}
32+
33+
/// <inheritdoc/>
34+
public async Task<BloomInformation> InfoAsync(RedisKey key)
35+
{
36+
var info = (await _db.ExecuteAsync(BloomCommandBuilder.Info(key)));
37+
return info.ToBloomInfo();
38+
}
39+
40+
/// <inheritdoc/>
41+
public async Task<bool[]> InsertAsync(RedisKey key, RedisValue[] items, int? capacity = null,
42+
double? error = null, int? expansion = null,
43+
bool nocreate = false, bool nonscaling = false)
44+
{
45+
return (await _db.ExecuteAsync(BloomCommandBuilder.Insert(key, items, capacity, error, expansion, nocreate, nonscaling))).ToBooleanArray();
46+
}
47+
48+
/// <inheritdoc/>
49+
public async Task<bool> LoadChunkAsync(RedisKey key, long iterator, Byte[] data)
50+
{
51+
return (await _db.ExecuteAsync(BloomCommandBuilder.LoadChunk(key, iterator, data))).OKtoBoolean();
52+
}
53+
54+
/// <inheritdoc/>
55+
public async Task<bool[]> MAddAsync(RedisKey key, params RedisValue[] items)
56+
{
57+
return (await _db.ExecuteAsync(BloomCommandBuilder.MAdd(key, items))).ToBooleanArray();
58+
}
59+
60+
/// <inheritdoc/>
61+
public async Task<bool[]> MExistsAsync(RedisKey key, RedisValue[] items)
62+
{
63+
return (await _db.ExecuteAsync(BloomCommandBuilder.MExists(key, items))).ToBooleanArray();
64+
}
65+
66+
/// <inheritdoc/>
67+
public async Task<bool> ReserveAsync(RedisKey key, double errorRate, long capacity,
68+
int? expansion = null, bool nonscaling = false)
69+
{
70+
return (await _db.ExecuteAsync(BloomCommandBuilder.Reserve(key, errorRate, capacity, expansion, nonscaling))).OKtoBoolean();
71+
}
72+
73+
/// <inheritdoc/>
74+
public async Task<Tuple<long, Byte[]>> ScanDumpAsync(RedisKey key, long iterator)
75+
{
76+
return (await _db.ExecuteAsync(BloomCommandBuilder.ScanDump(key, iterator))).ToScanDumpTuple();
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)