@@ -72,8 +72,7 @@ public async Task<bool> ExistsAsync(RedisKey key, RedisValue item)
72
72
/// <remarks><seealso href="https://redis.io/commands/bf.info"/></remarks>
73
73
public BloomInformation Info ( RedisKey key )
74
74
{
75
- var info = _db . Execute ( BF . INFO , key ) ;
76
- return ResponseParser . ToBloomInfo ( info ) ;
75
+ return _db . Execute ( BF . INFO , key ) . ToBloomInfo ( ) ;
77
76
}
78
77
79
78
/// <summary>
@@ -85,7 +84,7 @@ public BloomInformation Info(RedisKey key)
85
84
public async Task < BloomInformation > InfoAsync ( RedisKey key )
86
85
{
87
86
var info = await _db . ExecuteAsync ( BF . INFO , key ) ;
88
- return ResponseParser . ToBloomInfo ( info ) ;
87
+ return info . ToBloomInfo ( ) ;
89
88
}
90
89
91
90
/// <summary>
@@ -111,45 +110,9 @@ public bool[] Insert(RedisKey key, RedisValue[] items, int? capacity = null,
111
110
if ( items . Length < 1 )
112
111
throw new ArgumentOutOfRangeException ( nameof ( items ) ) ;
113
112
114
- List < object > args = new List < object > { key } ;
115
-
116
- if ( capacity != null )
117
- {
118
- args . Add ( BloomArgs . CAPACITY ) ;
119
- args . Add ( capacity ) ;
120
- }
121
-
122
-
123
- if ( error != null )
124
- {
125
- args . Add ( BloomArgs . ERROR ) ;
126
- args . Add ( error ) ;
127
- }
128
-
129
- if ( expansion != null )
130
- {
131
- args . Add ( BloomArgs . EXPANSION ) ;
132
- args . Add ( expansion ) ;
133
- }
134
-
135
- if ( nocreate )
136
- {
137
- args . Add ( BloomArgs . NOCREATE ) ;
138
-
139
- }
140
-
141
- if ( nonscaling )
142
- {
143
- args . Add ( BloomArgs . NONSCALING ) ;
144
- }
145
-
146
- args . Add ( BloomArgs . ITEMS ) ;
147
- foreach ( var item in items )
148
- {
149
- args . Add ( item ) ;
150
- }
151
-
152
- return ResponseParser . ToBooleanArray ( _db . Execute ( BF . INSERT , args ) ) ;
113
+ var args = BloomAux . BuildInsertArgs ( key , items , capacity , error , expansion , nocreate , nonscaling ) ;
114
+
115
+ return _db . Execute ( BF . INSERT , args ) . ToBooleanArray ( ) ;
153
116
}
154
117
155
118
/// <summary>
@@ -175,45 +138,10 @@ public async Task<bool[]> InsertAsync(RedisKey key, RedisValue[] items, int? cap
175
138
if ( items . Length < 1 )
176
139
throw new ArgumentOutOfRangeException ( nameof ( items ) ) ;
177
140
178
- List < object > args = new List < object > { key } ;
179
-
180
- if ( capacity != null )
181
- {
182
- args . Add ( BloomArgs . CAPACITY ) ;
183
- args . Add ( capacity ) ;
184
- }
185
-
186
- if ( error != null )
187
- {
188
- args . Add ( BloomArgs . ERROR ) ;
189
- args . Add ( error ) ;
190
- }
191
-
192
- if ( expansion != null )
193
- {
194
- args . Add ( BloomArgs . EXPANSION ) ;
195
- args . Add ( expansion ) ;
196
- }
197
-
198
- if ( nocreate )
199
- {
200
- args . Add ( BloomArgs . NOCREATE ) ;
201
-
202
- }
203
-
204
- if ( nonscaling )
205
- {
206
- args . Add ( BloomArgs . NONSCALING ) ;
207
- }
208
-
209
- args . Add ( BloomArgs . ITEMS ) ;
210
- foreach ( var item in items )
211
- {
212
- args . Add ( item ) ;
213
- }
141
+ var args = BloomAux . BuildInsertArgs ( key , items , capacity , error , expansion , nocreate , nonscaling ) ;
214
142
215
143
var result = await _db . ExecuteAsync ( BF . INSERT , args ) ;
216
- return ResponseParser . ToBooleanArray ( result ) ;
144
+ return result . ToBooleanArray ( ) ;
217
145
}
218
146
219
147
/// <summary>
@@ -226,7 +154,7 @@ public async Task<bool[]> InsertAsync(RedisKey key, RedisValue[] items, int? cap
226
154
/// <remarks><seealso href="https://redis.io/commands/bf.loadchunk"/></remarks>
227
155
public bool LoadChunk ( RedisKey key , long iterator , Byte [ ] data )
228
156
{
229
- return ResponseParser . OKtoBoolean ( _db . Execute ( BF . LOADCHUNK , key , iterator , data ) ) ;
157
+ return _db . Execute ( BF . LOADCHUNK , key , iterator , data ) . OKtoBoolean ( ) ;
230
158
}
231
159
232
160
/// <summary>
@@ -240,7 +168,7 @@ public bool LoadChunk(RedisKey key, long iterator, Byte[] data)
240
168
public async Task < bool > LoadChunkAsync ( RedisKey key , long iterator , Byte [ ] data )
241
169
{
242
170
var result = await _db . ExecuteAsync ( BF . LOADCHUNK , key , iterator , data ) ;
243
- return ResponseParser . OKtoBoolean ( result ) ;
171
+ return result . OKtoBoolean ( ) ;
244
172
}
245
173
246
174
/// <summary>
@@ -263,7 +191,7 @@ public bool[] MAdd(RedisKey key, params RedisValue[] items)
263
191
args . Add ( item ) ;
264
192
}
265
193
266
- return ResponseParser . ToBooleanArray ( _db . Execute ( BF . MADD , args ) ) ;
194
+ return _db . Execute ( BF . MADD , args ) . ToBooleanArray ( ) ;
267
195
}
268
196
269
197
/// <summary>
@@ -287,7 +215,7 @@ public async Task<bool[]> MAddAsync(RedisKey key, params RedisValue[] items)
287
215
}
288
216
289
217
var result = await _db . ExecuteAsync ( BF . MADD , args ) ;
290
- return ResponseParser . ToBooleanArray ( result ) ;
218
+ return result . ToBooleanArray ( ) ;
291
219
}
292
220
293
221
/// <summary>
@@ -310,7 +238,7 @@ public bool[] MExists(RedisKey key, RedisValue[] items)
310
238
args . Add ( item ) ;
311
239
}
312
240
313
- return ResponseParser . ToBooleanArray ( _db . Execute ( BF . MEXISTS , args ) ) ;
241
+ return _db . Execute ( BF . MEXISTS , args ) . ToBooleanArray ( ) ;
314
242
315
243
}
316
244
@@ -335,7 +263,7 @@ public async Task<bool[]> MExistsAsync(RedisKey key, RedisValue[] items)
335
263
}
336
264
337
265
var result = await _db . ExecuteAsync ( BF . MEXISTS , args ) ;
338
- return ResponseParser . ToBooleanArray ( result ) ;
266
+ return result . ToBooleanArray ( ) ;
339
267
340
268
}
341
269
@@ -366,7 +294,7 @@ public bool Reserve(RedisKey key, double errorRate, long capacity,
366
294
args . Add ( BloomArgs . NONSCALING ) ;
367
295
}
368
296
369
- return ResponseParser . OKtoBoolean ( _db . Execute ( BF . RESERVE , args ) ) ;
297
+ return _db . Execute ( BF . RESERVE , args ) . OKtoBoolean ( ) ;
370
298
}
371
299
372
300
/// <summary>
@@ -397,7 +325,7 @@ public async Task<bool> ReserveAsync(RedisKey key, double errorRate, long capaci
397
325
}
398
326
399
327
var result = await _db . ExecuteAsync ( BF . RESERVE , args ) ;
400
- return ResponseParser . OKtoBoolean ( result ) ;
328
+ return result . OKtoBoolean ( ) ;
401
329
}
402
330
403
331
/// <summary>
@@ -409,7 +337,7 @@ public async Task<bool> ReserveAsync(RedisKey key, double errorRate, long capaci
409
337
/// <remarks><seealso href="https://redis.io/commands/bf.scandump"/></remarks>
410
338
public Tuple < long , Byte [ ] > ScanDump ( RedisKey key , long iterator )
411
339
{
412
- return ResponseParser . ToScanDumpTuple ( _db . Execute ( BF . SCANDUMP , key , iterator ) ) ;
340
+ return _db . Execute ( BF . SCANDUMP , key , iterator ) . ToScanDumpTuple ( ) ;
413
341
}
414
342
415
343
/// <summary>
@@ -422,7 +350,7 @@ public Tuple<long,Byte[]> ScanDump(RedisKey key, long iterator)
422
350
public async Task < Tuple < long , Byte [ ] > > ScanDumpAsync ( RedisKey key , long iterator )
423
351
{
424
352
var result = await _db . ExecuteAsync ( BF . SCANDUMP , key , iterator ) ;
425
- return ResponseParser . ToScanDumpTuple ( result ) ;
353
+ return result . ToScanDumpTuple ( ) ;
426
354
}
427
355
}
428
356
}
0 commit comments