@@ -3102,6 +3102,7 @@ def hscan(
3102
3102
cursor : int = 0 ,
3103
3103
match : Union [PatternT , None ] = None ,
3104
3104
count : Union [int , None ] = None ,
3105
+ no_values : Union [bool , None ] = None ,
3105
3106
) -> ResponseT :
3106
3107
"""
3107
3108
Incrementally return key/value slices in a hash. Also return a cursor
@@ -3111,20 +3112,26 @@ def hscan(
3111
3112
3112
3113
``count`` allows for hint the minimum number of returns
3113
3114
3115
+ ``no_values`` indicates to return only the keys, without values. The
3116
+ return type in this case is a list of keys.
3117
+
3114
3118
For more information see https://redis.io/commands/hscan
3115
3119
"""
3116
3120
pieces : list [EncodableT ] = [name , cursor ]
3117
3121
if match is not None :
3118
3122
pieces .extend ([b"MATCH" , match ])
3119
3123
if count is not None :
3120
3124
pieces .extend ([b"COUNT" , count ])
3121
- return self .execute_command ("HSCAN" , * pieces )
3125
+ if no_values is not None :
3126
+ pieces .extend ([b"NOVALUES" ])
3127
+ return self .execute_command ("HSCAN" , * pieces , no_values = no_values )
3122
3128
3123
3129
def hscan_iter (
3124
3130
self ,
3125
3131
name : str ,
3126
3132
match : Union [PatternT , None ] = None ,
3127
3133
count : Union [int , None ] = None ,
3134
+ no_values : Union [bool , None ] = None ,
3128
3135
) -> Iterator :
3129
3136
"""
3130
3137
Make an iterator using the HSCAN command so that the client doesn't
@@ -3133,11 +3140,18 @@ def hscan_iter(
3133
3140
``match`` allows for filtering the keys by pattern
3134
3141
3135
3142
``count`` allows for hint the minimum number of returns
3143
+
3144
+ ``no_values`` indicates to return only the keys, without values
3136
3145
"""
3137
3146
cursor = "0"
3138
3147
while cursor != 0 :
3139
- cursor , data = self .hscan (name , cursor = cursor , match = match , count = count )
3140
- yield from data .items ()
3148
+ cursor , data = self .hscan (
3149
+ name , cursor = cursor , match = match , count = count , no_values = no_values
3150
+ )
3151
+ if no_values :
3152
+ yield from data
3153
+ else :
3154
+ yield from data .items ()
3141
3155
3142
3156
def zscan (
3143
3157
self ,
@@ -3253,6 +3267,7 @@ async def hscan_iter(
3253
3267
name : str ,
3254
3268
match : Union [PatternT , None ] = None ,
3255
3269
count : Union [int , None ] = None ,
3270
+ no_values : Union [bool , None ] = None ,
3256
3271
) -> AsyncIterator :
3257
3272
"""
3258
3273
Make an iterator using the HSCAN command so that the client doesn't
@@ -3261,11 +3276,13 @@ async def hscan_iter(
3261
3276
``match`` allows for filtering the keys by pattern
3262
3277
3263
3278
``count`` allows for hint the minimum number of returns
3279
+
3280
+ ``no_values`` indicates to return only the keys, without values
3264
3281
"""
3265
3282
cursor = "0"
3266
3283
while cursor != 0 :
3267
3284
cursor , data = await self .hscan (
3268
- name , cursor = cursor , match = match , count = count
3285
+ name , cursor = cursor , match = match , count = count , no_values = no_values
3269
3286
)
3270
3287
for it in data .items ():
3271
3288
yield it
0 commit comments