@@ -2239,22 +2239,18 @@ def evalsha(*args)
2239
2239
_eval ( :evalsha , args )
2240
2240
end
2241
2241
2242
- def _scan ( command , cursor , options = { } , &block )
2243
- # SSCAN/ZSCAN/HSCAN need a key to work on
2244
- args = [ ]
2245
-
2246
- if command != :scan
2247
- key = options [ :key ]
2248
- args . concat ( [ key ] ) if key
2249
- end
2242
+ def _scan ( command , cursor , args , options = { } , &block )
2243
+ # SSCAN/ZSCAN/HSCAN already prepend the key to +args+.
2250
2244
2251
- args . concat ( [ cursor ] )
2245
+ args << cursor
2252
2246
2253
- match = options [ :match ]
2254
- args . concat ( [ "MATCH" , match ] ) if match
2247
+ if match = options [ :match ]
2248
+ args . concat ( [ "MATCH" , match ] )
2249
+ end
2255
2250
2256
- count = options [ :count ]
2257
- args . concat ( [ "COUNT" , count ] ) if count
2251
+ if count = options [ :count ]
2252
+ args . concat ( [ "COUNT" , count ] )
2253
+ end
2258
2254
2259
2255
synchronize do |client |
2260
2256
client . call ( [ command ] + args , &block )
@@ -2277,7 +2273,7 @@ def _scan(command, cursor, options = {}, &block)
2277
2273
#
2278
2274
# @return [String, Array<String>] the next cursor and all found keys
2279
2275
def scan ( cursor , options = { } )
2280
- _scan ( :scan , cursor , options )
2276
+ _scan ( :scan , cursor , [ ] , options )
2281
2277
end
2282
2278
2283
2279
# Scan a hash
@@ -2292,7 +2288,7 @@ def scan(cursor, options={})
2292
2288
#
2293
2289
# @return [String, Array<[String, String]>] the next cursor and all found keys
2294
2290
def hscan ( key , cursor , options = { } )
2295
- _scan ( :hscan , cursor , options . merge ( : key => key ) ) do |reply |
2291
+ _scan ( :hscan , cursor , [ key ] , options ) do |reply |
2296
2292
[ reply [ 0 ] , _pairify ( reply [ 1 ] ) ]
2297
2293
end
2298
2294
end
@@ -2310,7 +2306,7 @@ def hscan(key, cursor, options={})
2310
2306
# @return [String, Array<[String, Float]>] the next cursor and all found
2311
2307
# members and scores
2312
2308
def zscan ( key , cursor , options = { } )
2313
- _scan ( :zscan , cursor , options . merge ( : key => key ) ) do |reply |
2309
+ _scan ( :zscan , cursor , [ key ] , options ) do |reply |
2314
2310
[ reply [ 0 ] , _floatify_pairs . call ( reply [ 1 ] ) ]
2315
2311
end
2316
2312
end
@@ -2327,7 +2323,7 @@ def zscan(key, cursor, options={})
2327
2323
#
2328
2324
# @return [String, Array<String>] the next cursor and all found members
2329
2325
def sscan ( key , cursor , options = { } )
2330
- _scan ( :sscan , cursor , options . merge ( : key => key ) )
2326
+ _scan ( :sscan , cursor , [ key ] , options )
2331
2327
end
2332
2328
2333
2329
def id
0 commit comments