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