@@ -242,18 +242,20 @@ def parse_script(response, **options):
242
242
243
243
244
244
def parse_scan (response , ** options ):
245
- return response
245
+ cursor , r = response
246
+ return nativestr (cursor ), r
246
247
247
248
248
249
def parse_hscan (response , ** options ):
249
250
cursor , r = response
250
- return cursor , r and pairs_to_dict (r ) or {}
251
+ return nativestr ( cursor ) , r and pairs_to_dict (r ) or {}
251
252
252
253
253
254
def parse_zscan (response , ** options ):
254
255
score_cast_func = options .get ('score_cast_func' , float )
255
- it = iter (response [1 ])
256
- return [response [0 ], list (izip (it , imap (score_cast_func , it )))]
256
+ cursor , r = response
257
+ it = iter (r )
258
+ return nativestr (cursor ), list (izip (it , imap (score_cast_func , it )))
257
259
258
260
259
261
class StrictRedis (object ):
@@ -1180,7 +1182,8 @@ def sort(self, name, start=None, num=None, by=None, get=None,
1180
1182
#### SCAN COMMANDS ####
1181
1183
def scan (self , cursor = 0 , match = None , count = None ):
1182
1184
"""
1183
- Scan and return (nextcursor, keys)
1185
+ Incrementally return lists of key names. Also return a cursor
1186
+ indicating the scan position.
1184
1187
1185
1188
``match`` allows for filtering the keys by pattern
1186
1189
@@ -1195,7 +1198,8 @@ def scan(self, cursor=0, match=None, count=None):
1195
1198
1196
1199
def scan_iter (self , match = None , count = None ):
1197
1200
"""
1198
- Make a iterator using scan.
1201
+ Make an iterator using the SCAN command so that the client doesn't
1202
+ need to remember the cursor position.
1199
1203
1200
1204
``match`` allows for filtering the keys by pattern
1201
1205
@@ -1204,12 +1208,13 @@ def scan_iter(self, match=None, count=None):
1204
1208
cursor = 0
1205
1209
while cursor != '0' :
1206
1210
cursor , data = self .scan (cursor = cursor , match = match , count = count )
1207
- for _ in data :
1208
- yield _
1211
+ for item in data :
1212
+ yield item
1209
1213
1210
1214
def sscan (self , name , cursor = 0 , match = None , count = None ):
1211
1215
"""
1212
- Scan and return (nextcursor, members_of_set)
1216
+ Incrementally return lists of elements in a set. Also return a cursor
1217
+ indicating the scan position.
1213
1218
1214
1219
``match`` allows for filtering the keys by pattern
1215
1220
@@ -1224,7 +1229,8 @@ def sscan(self, name, cursor=0, match=None, count=None):
1224
1229
1225
1230
def sscan_iter (self , name , match = None , count = None ):
1226
1231
"""
1227
- Make a iterator using sscan. Iterates over set members.
1232
+ Make an iterator using the SSCAN command so that the client doesn't
1233
+ need to remember the cursor position.
1228
1234
1229
1235
``match`` allows for filtering the keys by pattern
1230
1236
@@ -1234,12 +1240,13 @@ def sscan_iter(self, name, match=None, count=None):
1234
1240
while cursor != '0' :
1235
1241
cursor , data = self .sscan (name , cursor = cursor ,
1236
1242
match = match , count = count )
1237
- for _ in data :
1238
- yield _
1243
+ for item in data :
1244
+ yield item
1239
1245
1240
1246
def hscan (self , name , cursor = 0 , match = None , count = None ):
1241
1247
"""
1242
- Scan and return (nextcursor, dict)
1248
+ Incrementally return key/value slices in a hash. Also return a cursor
1249
+ indicating the scan position.
1243
1250
1244
1251
``match`` allows for filtering the keys by pattern
1245
1252
@@ -1254,7 +1261,8 @@ def hscan(self, name, cursor=0, match=None, count=None):
1254
1261
1255
1262
def hscan_iter (self , name , match = None , count = None ):
1256
1263
"""
1257
- Make a iterator using hscan. Iterates over key/value pairs.
1264
+ Make an iterator using the HSCAN command so that the client doesn't
1265
+ need to remember the cursor position.
1258
1266
1259
1267
``match`` allows for filtering the keys by pattern
1260
1268
@@ -1264,13 +1272,14 @@ def hscan_iter(self, name, match=None, count=None):
1264
1272
while cursor != '0' :
1265
1273
cursor , data = self .hscan (name , cursor = cursor ,
1266
1274
match = match , count = count )
1267
- for _ in data .items ():
1268
- yield _
1275
+ for item in data .items ():
1276
+ yield item
1269
1277
1270
1278
def zscan (self , name , cursor = 0 , match = None , count = None ,
1271
1279
score_cast_func = float ):
1272
1280
"""
1273
- Scan and return (nextcursor, pairs)
1281
+ Incrementally return lists of elements in a sorted set. Also return a
1282
+ cursor indicating the scan position.
1274
1283
1275
1284
``match`` allows for filtering the keys by pattern
1276
1285
@@ -1289,7 +1298,8 @@ def zscan(self, name, cursor=0, match=None, count=None,
1289
1298
def zscan_iter (self , name , match = None , count = None ,
1290
1299
score_cast_func = float ):
1291
1300
"""
1292
- Make a iterator using zscan. Iterates over key/score pairs.
1301
+ Make an iterator using the ZSCAN command so that the client doesn't
1302
+ need to remember the cursor position.
1293
1303
1294
1304
``match`` allows for filtering the keys by pattern
1295
1305
@@ -1302,8 +1312,8 @@ def zscan_iter(self, name, match=None, count=None,
1302
1312
cursor , data = self .zscan (name , cursor = cursor , match = match ,
1303
1313
count = count ,
1304
1314
score_cast_func = score_cast_func )
1305
- for _ in data :
1306
- yield _
1315
+ for item in data :
1316
+ yield item
1307
1317
1308
1318
#### SET COMMANDS ####
1309
1319
def sadd (self , name , * values ):
0 commit comments