valkey-glide 1.3.4rc6__cp313-cp313-macosx_11_0_arm64.whl → 2.0.0rc2__cp313-cp313-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of valkey-glide might be problematic. Click here for more details.
- glide/__init__.py +11 -7
- glide/async_commands/{transaction.py → batch.py} +1380 -970
- glide/async_commands/bitmap.py +94 -85
- glide/async_commands/cluster_commands.py +301 -122
- glide/async_commands/command_args.py +7 -6
- glide/async_commands/core.py +1281 -696
- glide/async_commands/server_modules/ft.py +83 -14
- glide/async_commands/server_modules/ft_options/ft_aggregate_options.py +15 -8
- glide/async_commands/server_modules/ft_options/ft_create_options.py +23 -11
- glide/async_commands/server_modules/ft_options/ft_profile_options.py +12 -7
- glide/async_commands/server_modules/ft_options/ft_search_options.py +12 -6
- glide/async_commands/server_modules/glide_json.py +134 -43
- glide/async_commands/server_modules/json_batch.py +157 -127
- glide/async_commands/sorted_set.py +39 -29
- glide/async_commands/standalone_commands.py +193 -96
- glide/async_commands/stream.py +94 -87
- glide/config.py +165 -105
- glide/constants.py +8 -4
- glide/glide.cpython-313-darwin.so +0 -0
- glide/glide_client.py +83 -10
- glide/logger.py +1 -1
- glide/protobuf/command_request_pb2.py +15 -15
- glide/protobuf/command_request_pb2.pyi +69 -46
- glide/protobuf/connection_request_pb2.py +15 -13
- glide/protobuf/connection_request_pb2.pyi +57 -29
- glide/protobuf/response_pb2.pyi +8 -9
- glide/protobuf_codec.py +7 -6
- glide/routes.py +16 -8
- {valkey_glide-1.3.4rc6.dist-info → valkey_glide-2.0.0rc2.dist-info}/METADATA +9 -5
- valkey_glide-2.0.0rc2.dist-info/RECORD +37 -0
- valkey_glide-1.3.4rc6.dist-info/RECORD +0 -37
- {valkey_glide-1.3.4rc6.dist-info → valkey_glide-2.0.0rc2.dist-info}/WHEEL +0 -0
glide/async_commands/core.py
CHANGED
|
@@ -19,7 +19,6 @@ from typing import (
|
|
|
19
19
|
from glide.async_commands.bitmap import (
|
|
20
20
|
BitFieldGet,
|
|
21
21
|
BitFieldSubCommands,
|
|
22
|
-
BitmapIndexType,
|
|
23
22
|
BitwiseOperation,
|
|
24
23
|
OffsetOptions,
|
|
25
24
|
_create_bitfield_args,
|
|
@@ -71,12 +70,13 @@ from ..glide import ClusterScanCursor
|
|
|
71
70
|
class ConditionalChange(Enum):
|
|
72
71
|
"""
|
|
73
72
|
A condition to the `SET`, `ZADD` and `GEOADD` commands.
|
|
74
|
-
- ONLY_IF_EXISTS - Only update key / elements that already exist. Equivalent to `XX` in the Valkey API.
|
|
75
|
-
- ONLY_IF_DOES_NOT_EXIST - Only set key / add elements that does not already exist. Equivalent to `NX` in the Valkey API.
|
|
76
73
|
"""
|
|
77
74
|
|
|
78
75
|
ONLY_IF_EXISTS = "XX"
|
|
76
|
+
""" Only update key / elements that already exist. Equivalent to `XX` in the Valkey API. """
|
|
77
|
+
|
|
79
78
|
ONLY_IF_DOES_NOT_EXIST = "NX"
|
|
79
|
+
""" Only set key / add elements that does not already exist. Equivalent to `NX` in the Valkey API. """
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
@dataclass
|
|
@@ -84,7 +84,9 @@ class OnlyIfEqual:
|
|
|
84
84
|
"""
|
|
85
85
|
Change condition to the `SET` command,
|
|
86
86
|
For additional conditonal options see ConditionalChange
|
|
87
|
+
|
|
87
88
|
- comparison_value - value to compare to the current value of a key.
|
|
89
|
+
|
|
88
90
|
If comparison_value is equal to the key, it will overwrite the value of key to the new provided value
|
|
89
91
|
Equivalent to the IFEQ comparison-value in the Valkey API
|
|
90
92
|
"""
|
|
@@ -93,130 +95,164 @@ class OnlyIfEqual:
|
|
|
93
95
|
|
|
94
96
|
|
|
95
97
|
class ExpiryType(Enum):
|
|
96
|
-
"""
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
"""
|
|
99
|
+
SET option: The type of the expiry.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
SEC = 0, Union[int, timedelta]
|
|
103
|
+
"""
|
|
104
|
+
Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API.
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
MILLSEC = 1, Union[int, timedelta]
|
|
108
|
+
"""
|
|
109
|
+
Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
UNIX_SEC = 2, Union[int, datetime]
|
|
113
|
+
"""
|
|
114
|
+
Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API.
|
|
103
115
|
"""
|
|
104
116
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
UNIX_MILLSEC = 3, Union[int, datetime]
|
|
118
|
+
"""
|
|
119
|
+
Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
KEEP_TTL = 4, Type[None]
|
|
123
|
+
"""
|
|
124
|
+
Retain the time to live associated with the key. Equivalent to `KEEPTTL` in the Valkey API.
|
|
125
|
+
"""
|
|
110
126
|
|
|
111
127
|
|
|
112
128
|
class ExpiryTypeGetEx(Enum):
|
|
113
|
-
"""GetEx option: The type of the expiry.
|
|
114
|
-
- EX - Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API.
|
|
115
|
-
- PX - Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API.
|
|
116
|
-
- UNIX_SEC - Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API.
|
|
117
|
-
- UNIX_MILLSEC - Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the
|
|
118
|
-
Valkey API.
|
|
119
|
-
- PERSIST - Remove the time to live associated with the key. Equivalent to `PERSIST` in the Valkey API.
|
|
120
129
|
"""
|
|
130
|
+
GetEx option: The type of the expiry.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
SEC = 0, Union[int, timedelta]
|
|
134
|
+
""" Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API. """
|
|
121
135
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
MILLSEC = 1, Union[int, timedelta]
|
|
137
|
+
""" Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API. """
|
|
138
|
+
|
|
139
|
+
UNIX_SEC = 2, Union[int, datetime]
|
|
140
|
+
""" Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API. """
|
|
141
|
+
|
|
142
|
+
UNIX_MILLSEC = 3, Union[int, datetime]
|
|
143
|
+
""" Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API. """
|
|
144
|
+
|
|
145
|
+
PERSIST = 4, Type[None]
|
|
146
|
+
""" Remove the time to live associated with the key. Equivalent to `PERSIST` in the Valkey API. """
|
|
127
147
|
|
|
128
148
|
|
|
129
149
|
class InfoSection(Enum):
|
|
130
150
|
"""
|
|
131
151
|
INFO option: a specific section of information:
|
|
132
152
|
|
|
133
|
-
-SERVER: General information about the server
|
|
134
|
-
-CLIENTS: Client connections section
|
|
135
|
-
-MEMORY: Memory consumption related information
|
|
136
|
-
-PERSISTENCE: RDB and AOF related information
|
|
137
|
-
-STATS: General statistics
|
|
138
|
-
-REPLICATION: Master/replica replication information
|
|
139
|
-
-CPU: CPU consumption statistics
|
|
140
|
-
-COMMANDSTATS: Valkey command statistics
|
|
141
|
-
-LATENCYSTATS: Valkey command latency percentile distribution statistics
|
|
142
|
-
-SENTINEL: Valkey Sentinel section (only applicable to Sentinel instances)
|
|
143
|
-
-CLUSTER: Valkey Cluster section
|
|
144
|
-
-MODULES: Modules section
|
|
145
|
-
-KEYSPACE: Database related statistics
|
|
146
|
-
-ERRORSTATS: Valkey error statistics
|
|
147
|
-
-ALL: Return all sections (excluding module generated ones)
|
|
148
|
-
-DEFAULT: Return only the default set of sections
|
|
149
|
-
-EVERYTHING: Includes all and modules
|
|
150
153
|
When no parameter is provided, the default option is assumed.
|
|
151
154
|
"""
|
|
152
155
|
|
|
153
156
|
SERVER = "server"
|
|
157
|
+
""" General information about the server """
|
|
158
|
+
|
|
154
159
|
CLIENTS = "clients"
|
|
160
|
+
""" Client connections section """
|
|
161
|
+
|
|
155
162
|
MEMORY = "memory"
|
|
163
|
+
""" Memory consumption related information """
|
|
164
|
+
|
|
156
165
|
PERSISTENCE = "persistence"
|
|
166
|
+
""" RDB and AOF related information """
|
|
167
|
+
|
|
157
168
|
STATS = "stats"
|
|
169
|
+
""" General statistics """
|
|
170
|
+
|
|
158
171
|
REPLICATION = "replication"
|
|
172
|
+
""" Master/replica replication information """
|
|
173
|
+
|
|
159
174
|
CPU = "cpu"
|
|
175
|
+
""" CPU consumption statistics """
|
|
176
|
+
|
|
160
177
|
COMMAND_STATS = "commandstats"
|
|
178
|
+
""" Valkey command statistics """
|
|
179
|
+
|
|
161
180
|
LATENCY_STATS = "latencystats"
|
|
181
|
+
""" Valkey command latency percentile distribution statistics """
|
|
182
|
+
|
|
162
183
|
SENTINEL = "sentinel"
|
|
184
|
+
""" Valkey Sentinel section (only applicable to Sentinel instances) """
|
|
185
|
+
|
|
163
186
|
CLUSTER = "cluster"
|
|
187
|
+
""" Valkey Cluster section """
|
|
188
|
+
|
|
164
189
|
MODULES = "modules"
|
|
190
|
+
""" Modules section """
|
|
191
|
+
|
|
165
192
|
KEYSPACE = "keyspace"
|
|
193
|
+
""" Database related statistics """
|
|
194
|
+
|
|
166
195
|
ERROR_STATS = "errorstats"
|
|
196
|
+
""" Valkey error statistics """
|
|
197
|
+
|
|
167
198
|
ALL = "all"
|
|
199
|
+
""" Return all sections (excluding module generated ones) """
|
|
200
|
+
|
|
168
201
|
DEFAULT = "default"
|
|
202
|
+
""" Return only the default set of sections """
|
|
203
|
+
|
|
169
204
|
EVERYTHING = "everything"
|
|
205
|
+
""" Includes all and modules """
|
|
170
206
|
|
|
171
207
|
|
|
172
208
|
class ExpireOptions(Enum):
|
|
173
209
|
"""
|
|
174
210
|
EXPIRE option: options for setting key expiry.
|
|
175
|
-
|
|
176
|
-
- HasNoExpiry: Set expiry only when the key has no expiry (Equivalent to "NX" in Valkey).
|
|
177
|
-
- HasExistingExpiry: Set expiry only when the key has an existing expiry (Equivalent to "XX" in Valkey).
|
|
178
|
-
- NewExpiryGreaterThanCurrent: Set expiry only when the new expiry is greater than the current one (Equivalent
|
|
179
|
-
to "GT" in Valkey).
|
|
180
|
-
- NewExpiryLessThanCurrent: Set expiry only when the new expiry is less than the current one (Equivalent to "LT" in Valkey).
|
|
181
211
|
"""
|
|
182
212
|
|
|
183
213
|
HasNoExpiry = "NX"
|
|
214
|
+
""" Set expiry only when the key has no expiry (Equivalent to "NX" in Valkey). """
|
|
215
|
+
|
|
184
216
|
HasExistingExpiry = "XX"
|
|
217
|
+
""" Set expiry only when the key has an existing expiry (Equivalent to "XX" in Valkey). """
|
|
218
|
+
|
|
185
219
|
NewExpiryGreaterThanCurrent = "GT"
|
|
220
|
+
"""
|
|
221
|
+
Set expiry only when the new expiry is greater than the current one (Equivalent to "GT" in Valkey).
|
|
222
|
+
"""
|
|
223
|
+
|
|
186
224
|
NewExpiryLessThanCurrent = "LT"
|
|
225
|
+
"""
|
|
226
|
+
Set expiry only when the new expiry is less than the current one (Equivalent to "LT" in Valkey).
|
|
227
|
+
"""
|
|
187
228
|
|
|
188
229
|
|
|
189
230
|
class UpdateOptions(Enum):
|
|
190
231
|
"""
|
|
191
232
|
Options for updating elements of a sorted set key.
|
|
192
|
-
|
|
193
|
-
- LESS_THAN: Only update existing elements if the new score is less than the current score.
|
|
194
|
-
- GREATER_THAN: Only update existing elements if the new score is greater than the current score.
|
|
195
233
|
"""
|
|
196
234
|
|
|
197
235
|
LESS_THAN = "LT"
|
|
236
|
+
""" Only update existing elements if the new score is less than the current score. """
|
|
237
|
+
|
|
198
238
|
GREATER_THAN = "GT"
|
|
239
|
+
""" Only update existing elements if the new score is greater than the current score. """
|
|
199
240
|
|
|
200
241
|
|
|
201
242
|
class ExpirySet:
|
|
202
|
-
"""
|
|
243
|
+
"""
|
|
244
|
+
SET option: Represents the expiry type and value to be executed with "SET" command.
|
|
245
|
+
|
|
246
|
+
Attributes:
|
|
247
|
+
cmd_arg (str): The expiry type.
|
|
248
|
+
value (str): The value for the expiry type.
|
|
249
|
+
"""
|
|
203
250
|
|
|
204
251
|
def __init__(
|
|
205
252
|
self,
|
|
206
253
|
expiry_type: ExpiryType,
|
|
207
254
|
value: Optional[Union[int, datetime, timedelta]],
|
|
208
255
|
) -> None:
|
|
209
|
-
"""
|
|
210
|
-
Args:
|
|
211
|
-
- expiry_type (ExpiryType): The expiry type.
|
|
212
|
-
- value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
|
|
213
|
-
determines the type of expiration value:
|
|
214
|
-
- SEC: Union[int, timedelta]
|
|
215
|
-
- MILLSEC: Union[int, timedelta]
|
|
216
|
-
- UNIX_SEC: Union[int, datetime]
|
|
217
|
-
- UNIX_MILLSEC: Union[int, datetime]
|
|
218
|
-
- KEEP_TTL: Type[None]
|
|
219
|
-
"""
|
|
220
256
|
self.set_expiry_type_and_value(expiry_type, value)
|
|
221
257
|
|
|
222
258
|
def __eq__(self, other: "object") -> bool:
|
|
@@ -227,6 +263,18 @@ class ExpirySet:
|
|
|
227
263
|
def set_expiry_type_and_value(
|
|
228
264
|
self, expiry_type: ExpiryType, value: Optional[Union[int, datetime, timedelta]]
|
|
229
265
|
):
|
|
266
|
+
"""
|
|
267
|
+
Args:
|
|
268
|
+
expiry_type (ExpiryType): The expiry type.
|
|
269
|
+
value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
|
|
270
|
+
determines the type of expiration value:
|
|
271
|
+
|
|
272
|
+
- SEC: Union[int, timedelta]
|
|
273
|
+
- MILLSEC: Union[int, timedelta]
|
|
274
|
+
- UNIX_SEC: Union[int, datetime]
|
|
275
|
+
- UNIX_MILLSEC: Union[int, datetime]
|
|
276
|
+
- KEEP_TTL: Type[None]
|
|
277
|
+
"""
|
|
230
278
|
if not isinstance(value, get_args(expiry_type.value[1])):
|
|
231
279
|
raise ValueError(
|
|
232
280
|
f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
|
|
@@ -257,24 +305,19 @@ class ExpirySet:
|
|
|
257
305
|
|
|
258
306
|
|
|
259
307
|
class ExpiryGetEx:
|
|
260
|
-
"""
|
|
308
|
+
"""
|
|
309
|
+
GetEx option: Represents the expiry type and value to be executed with "GetEx" command.
|
|
310
|
+
|
|
311
|
+
Attributes:
|
|
312
|
+
cmd_arg (str): The expiry type.
|
|
313
|
+
value (str): The value for the expiry type.
|
|
314
|
+
"""
|
|
261
315
|
|
|
262
316
|
def __init__(
|
|
263
317
|
self,
|
|
264
318
|
expiry_type: ExpiryTypeGetEx,
|
|
265
319
|
value: Optional[Union[int, datetime, timedelta]],
|
|
266
320
|
) -> None:
|
|
267
|
-
"""
|
|
268
|
-
Args:
|
|
269
|
-
- expiry_type (ExpiryType): The expiry type.
|
|
270
|
-
- value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
|
|
271
|
-
determines the type of expiration value:
|
|
272
|
-
- SEC: Union[int, timedelta]
|
|
273
|
-
- MILLSEC: Union[int, timedelta]
|
|
274
|
-
- UNIX_SEC: Union[int, datetime]
|
|
275
|
-
- UNIX_MILLSEC: Union[int, datetime]
|
|
276
|
-
- PERSIST: Type[None]
|
|
277
|
-
"""
|
|
278
321
|
self.set_expiry_type_and_value(expiry_type, value)
|
|
279
322
|
|
|
280
323
|
def set_expiry_type_and_value(
|
|
@@ -282,6 +325,18 @@ class ExpiryGetEx:
|
|
|
282
325
|
expiry_type: ExpiryTypeGetEx,
|
|
283
326
|
value: Optional[Union[int, datetime, timedelta]],
|
|
284
327
|
):
|
|
328
|
+
"""
|
|
329
|
+
Args:
|
|
330
|
+
expiry_type (ExpiryType): The expiry type.
|
|
331
|
+
value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
|
|
332
|
+
determines the type of expiration value:
|
|
333
|
+
|
|
334
|
+
- SEC: Union[int, timedelta]
|
|
335
|
+
- MILLSEC: Union[int, timedelta]
|
|
336
|
+
- UNIX_SEC: Union[int, datetime]
|
|
337
|
+
- UNIX_MILLSEC: Union[int, datetime]
|
|
338
|
+
- PERSIST: Type[None]
|
|
339
|
+
"""
|
|
285
340
|
if not isinstance(value, get_args(expiry_type.value[1])):
|
|
286
341
|
raise ValueError(
|
|
287
342
|
f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
|
|
@@ -322,7 +377,8 @@ class FlushMode(Enum):
|
|
|
322
377
|
|
|
323
378
|
`FLUSHALL` command and `FUNCTION FLUSH` command.
|
|
324
379
|
|
|
325
|
-
See https://valkey.io/commands/flushall/ and https://valkey.io/commands/function-flush/
|
|
380
|
+
See [FLUSHAL](https://valkey.io/commands/flushall/) and [FUNCTION-FLUSH](https://valkey.io/commands/function-flush/)
|
|
381
|
+
for details
|
|
326
382
|
|
|
327
383
|
SYNC was introduced in version 6.2.0.
|
|
328
384
|
"""
|
|
@@ -334,17 +390,19 @@ class FlushMode(Enum):
|
|
|
334
390
|
class FunctionRestorePolicy(Enum):
|
|
335
391
|
"""
|
|
336
392
|
Options for the FUNCTION RESTORE command.
|
|
337
|
-
|
|
338
|
-
- APPEND: Appends the restored libraries to the existing libraries and aborts on collision. This is the
|
|
339
|
-
default policy.
|
|
340
|
-
- FLUSH: Deletes all existing libraries before restoring the payload.
|
|
341
|
-
- REPLACE: Appends the restored libraries to the existing libraries, replacing any existing ones in case
|
|
342
|
-
of name collisions. Note that this policy doesn't prevent function name collisions, only libraries.
|
|
343
393
|
"""
|
|
344
394
|
|
|
345
395
|
APPEND = "APPEND"
|
|
396
|
+
""" Appends the restored libraries to the existing libraries and aborts on collision. This is the default policy. """
|
|
397
|
+
|
|
346
398
|
FLUSH = "FLUSH"
|
|
399
|
+
""" Deletes all existing libraries before restoring the payload. """
|
|
400
|
+
|
|
347
401
|
REPLACE = "REPLACE"
|
|
402
|
+
"""
|
|
403
|
+
Appends the restored libraries to the existing libraries, replacing any existing ones in case
|
|
404
|
+
of name collisions. Note that this policy doesn't prevent function name collisions, only libraries.
|
|
405
|
+
"""
|
|
348
406
|
|
|
349
407
|
|
|
350
408
|
def _build_sort_args(
|
|
@@ -388,10 +446,15 @@ class CoreCommands(Protocol):
|
|
|
388
446
|
route: Optional[Route] = ...,
|
|
389
447
|
) -> TResult: ...
|
|
390
448
|
|
|
391
|
-
async def
|
|
449
|
+
async def _execute_batch(
|
|
392
450
|
self,
|
|
393
451
|
commands: List[Tuple[RequestType.ValueType, List[TEncodable]]],
|
|
452
|
+
is_atomic: bool,
|
|
453
|
+
raise_on_error: bool,
|
|
454
|
+
retry_server_error: bool = False,
|
|
455
|
+
retry_connection_error: bool = False,
|
|
394
456
|
route: Optional[Route] = None,
|
|
457
|
+
timeout: Optional[int] = None,
|
|
395
458
|
) -> List[TResult]: ...
|
|
396
459
|
|
|
397
460
|
async def _execute_script(
|
|
@@ -421,8 +484,9 @@ class CoreCommands(Protocol):
|
|
|
421
484
|
"""
|
|
422
485
|
Update the current connection password with a new password.
|
|
423
486
|
|
|
424
|
-
|
|
425
|
-
|
|
487
|
+
Note:
|
|
488
|
+
This method updates the client's internal password configuration and does
|
|
489
|
+
not perform password rotation on the server side.
|
|
426
490
|
|
|
427
491
|
This method is useful in scenarios where the server password has changed or when
|
|
428
492
|
utilizing short-lived passwords for enhanced security. It allows the client to
|
|
@@ -432,11 +496,11 @@ class CoreCommands(Protocol):
|
|
|
432
496
|
|
|
433
497
|
Args:
|
|
434
498
|
password (`Optional[str]`): The new password to use for the connection,
|
|
435
|
-
|
|
499
|
+
if `None` the password will be removed.
|
|
436
500
|
immediate_auth (`bool`):
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
501
|
+
`True`: The client will authenticate immediately with the new password against all connections, Using `AUTH`
|
|
502
|
+
command. If password supplied is an empty string, auth will not be performed and warning will be returned.
|
|
503
|
+
The default is `False`.
|
|
440
504
|
|
|
441
505
|
Returns:
|
|
442
506
|
TOK: A simple OK response. If `immediate_auth=True` returns OK if the reauthenticate succeed.
|
|
@@ -459,7 +523,8 @@ class CoreCommands(Protocol):
|
|
|
459
523
|
) -> Optional[bytes]:
|
|
460
524
|
"""
|
|
461
525
|
Set the given key with the given value. Return value is dependent on the passed options.
|
|
462
|
-
|
|
526
|
+
|
|
527
|
+
See [valkey.io](https://valkey.io/commands/set/) for more details.
|
|
463
528
|
|
|
464
529
|
Args:
|
|
465
530
|
key (TEncodable): the key to store.
|
|
@@ -473,27 +538,34 @@ class CoreCommands(Protocol):
|
|
|
473
538
|
Equivalent to `GET` in the Valkey API. Defaults to False.
|
|
474
539
|
|
|
475
540
|
Returns:
|
|
476
|
-
Optional[bytes]:
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
541
|
+
Optional[bytes]: If the value is successfully set, return OK.
|
|
542
|
+
|
|
543
|
+
If value isn't set because of `only_if_exists` or `only_if_does_not_exist` conditions, return `None`.
|
|
544
|
+
|
|
545
|
+
If return_old_value is set, return the old value as a bytes string.
|
|
480
546
|
|
|
481
547
|
Example:
|
|
482
548
|
>>> await client.set(b"key", b"value")
|
|
483
549
|
'OK'
|
|
484
|
-
|
|
485
550
|
# ONLY_IF_EXISTS -> Only set the key if it already exists
|
|
486
551
|
# expiry -> Set the amount of time until key expires
|
|
487
|
-
>>> await client.set(
|
|
552
|
+
>>> await client.set(
|
|
553
|
+
... "key",
|
|
554
|
+
... "new_value",
|
|
555
|
+
... conditional_set=ConditionalChange.ONLY_IF_EXISTS,
|
|
556
|
+
... expiry=ExpirySet(ExpiryType.SEC, 5)
|
|
557
|
+
... )
|
|
488
558
|
'OK' # Set "new_value" to "key" only if "key" already exists, and set the key expiration to 5 seconds.
|
|
489
|
-
|
|
490
559
|
# ONLY_IF_DOES_NOT_EXIST -> Only set key if it does not already exist
|
|
491
|
-
>>> await client.set(
|
|
560
|
+
>>> await client.set(
|
|
561
|
+
... "key",
|
|
562
|
+
... "value",
|
|
563
|
+
... conditional_set=ConditionalChange.ONLY_IF_DOES_NOT_EXIST,
|
|
564
|
+
... return_old_value=True
|
|
565
|
+
... )
|
|
492
566
|
b'new_value' # Returns the old value of "key".
|
|
493
567
|
>>> await client.get("key")
|
|
494
568
|
b'new_value' # Value wasn't modified back to being "value" because of "NX" flag.
|
|
495
|
-
|
|
496
|
-
|
|
497
569
|
# ONLY_IF_EQUAL -> Only set key if provided value is equal to current value of the key
|
|
498
570
|
>>> await client.set("key", "value")
|
|
499
571
|
'OK' # Reset "key" to "value"
|
|
@@ -522,13 +594,16 @@ class CoreCommands(Protocol):
|
|
|
522
594
|
async def get(self, key: TEncodable) -> Optional[bytes]:
|
|
523
595
|
"""
|
|
524
596
|
Get the value associated with the given key, or null if no such value exists.
|
|
525
|
-
|
|
597
|
+
|
|
598
|
+
See [valkey.io](https://valkey.io/commands/get/) for details.
|
|
526
599
|
|
|
527
600
|
Args:
|
|
528
601
|
key (TEncodable): The key to retrieve from the database.
|
|
529
602
|
|
|
530
603
|
Returns:
|
|
531
|
-
Optional[bytes]: If the key exists, returns the value of the key as a byte string.
|
|
604
|
+
Optional[bytes]: If the key exists, returns the value of the key as a byte string.
|
|
605
|
+
|
|
606
|
+
Otherwise, return None.
|
|
532
607
|
|
|
533
608
|
Example:
|
|
534
609
|
>>> await client.get("key")
|
|
@@ -541,13 +616,15 @@ class CoreCommands(Protocol):
|
|
|
541
616
|
"""
|
|
542
617
|
Gets a value associated with the given string `key` and deletes the key.
|
|
543
618
|
|
|
544
|
-
See https://valkey.io/commands/getdel for more details.
|
|
619
|
+
See [valkey.io](https://valkey.io/commands/getdel) for more details.
|
|
545
620
|
|
|
546
621
|
Args:
|
|
547
622
|
key (TEncodable): The `key` to retrieve from the database.
|
|
548
623
|
|
|
549
624
|
Returns:
|
|
550
|
-
Optional[bytes]: If `key` exists, returns the `value` of `key`.
|
|
625
|
+
Optional[bytes]: If `key` exists, returns the `value` of `key`.
|
|
626
|
+
|
|
627
|
+
Otherwise, returns `None`.
|
|
551
628
|
|
|
552
629
|
Examples:
|
|
553
630
|
>>> await client.set("key", "value")
|
|
@@ -569,7 +646,7 @@ class CoreCommands(Protocol):
|
|
|
569
646
|
If `key` does not exist, an empty byte string is returned. If `start` or `end`
|
|
570
647
|
are out of range, returns the substring within the valid range of the value.
|
|
571
648
|
|
|
572
|
-
See https://valkey.io/commands/getrange/ for more details.
|
|
649
|
+
See [valkey.io](https://valkey.io/commands/getrange/) for more details.
|
|
573
650
|
|
|
574
651
|
Args:
|
|
575
652
|
key (TEncodable): The key of the string.
|
|
@@ -600,9 +677,11 @@ class CoreCommands(Protocol):
|
|
|
600
677
|
async def append(self, key: TEncodable, value: TEncodable) -> int:
|
|
601
678
|
"""
|
|
602
679
|
Appends a value to a key.
|
|
603
|
-
If `key` does not exist it is created and set as an empty string, so `APPEND` will be similar to `SET` in this special case.
|
|
604
680
|
|
|
605
|
-
|
|
681
|
+
If `key` does not exist it is created and set as an empty string, so `APPEND` will be similar to `SET` in this special
|
|
682
|
+
case.
|
|
683
|
+
|
|
684
|
+
See [valkey.io](https://valkey.io/commands/append) for more details.
|
|
606
685
|
|
|
607
686
|
Args:
|
|
608
687
|
key (TEncodable): The key to which the value will be appended.
|
|
@@ -613,9 +692,11 @@ class CoreCommands(Protocol):
|
|
|
613
692
|
|
|
614
693
|
Examples:
|
|
615
694
|
>>> await client.append("key", "Hello")
|
|
616
|
-
5 # Indicates that "Hello" has been appended to the value of "key", which was initially empty, resulting in a
|
|
695
|
+
5 # Indicates that "Hello" has been appended to the value of "key", which was initially empty, resulting in a
|
|
696
|
+
# new value of "Hello" with a length of 5 - similar to the set operation.
|
|
617
697
|
>>> await client.append("key", " world")
|
|
618
|
-
11 # Indicates that " world" has been appended to the value of "key", resulting in a new value of
|
|
698
|
+
11 # Indicates that " world" has been appended to the value of "key", resulting in a new value of
|
|
699
|
+
# "Hello world" with a length of 11.
|
|
619
700
|
>>> await client.get("key")
|
|
620
701
|
b"Hello world" # Returns the value stored in "key", which is now "Hello world".
|
|
621
702
|
"""
|
|
@@ -624,14 +705,16 @@ class CoreCommands(Protocol):
|
|
|
624
705
|
async def strlen(self, key: TEncodable) -> int:
|
|
625
706
|
"""
|
|
626
707
|
Get the length of the string value stored at `key`.
|
|
627
|
-
|
|
708
|
+
|
|
709
|
+
See [valkey.io](https://valkey.io/commands/strlen/) for more details.
|
|
628
710
|
|
|
629
711
|
Args:
|
|
630
712
|
key (TEncodable): The key to return its length.
|
|
631
713
|
|
|
632
714
|
Returns:
|
|
633
715
|
int: The length of the string value stored at `key`.
|
|
634
|
-
|
|
716
|
+
|
|
717
|
+
If `key` does not exist, it is treated as an empty string and 0 is returned.
|
|
635
718
|
|
|
636
719
|
Examples:
|
|
637
720
|
>>> await client.set("key", "GLIDE")
|
|
@@ -645,17 +728,20 @@ class CoreCommands(Protocol):
|
|
|
645
728
|
"""
|
|
646
729
|
Renames `key` to `new_key`.
|
|
647
730
|
If `newkey` already exists it is overwritten.
|
|
648
|
-
|
|
731
|
+
|
|
732
|
+
See [valkey.io](https://valkey.io/commands/rename/) for more details.
|
|
649
733
|
|
|
650
734
|
Note:
|
|
651
735
|
When in cluster mode, both `key` and `newkey` must map to the same hash slot.
|
|
652
736
|
|
|
653
737
|
Args:
|
|
654
|
-
key (TEncodable)
|
|
655
|
-
new_key (TEncodable)
|
|
738
|
+
key (TEncodable): The key to rename.
|
|
739
|
+
new_key (TEncodable): The new name of the key.
|
|
656
740
|
|
|
657
741
|
Returns:
|
|
658
|
-
OK: If the `key` was successfully renamed, return "OK".
|
|
742
|
+
OK: If the `key` was successfully renamed, return "OK".
|
|
743
|
+
|
|
744
|
+
If `key` does not exist, an error is thrown.
|
|
659
745
|
"""
|
|
660
746
|
return cast(
|
|
661
747
|
TOK, await self._execute_command(RequestType.Rename, [key, new_key])
|
|
@@ -665,7 +751,7 @@ class CoreCommands(Protocol):
|
|
|
665
751
|
"""
|
|
666
752
|
Renames `key` to `new_key` if `new_key` does not yet exist.
|
|
667
753
|
|
|
668
|
-
See https://valkey.io/commands/renamenx for more details.
|
|
754
|
+
See [valkey.io](https://valkey.io/commands/renamenx) for more details.
|
|
669
755
|
|
|
670
756
|
Note:
|
|
671
757
|
When in cluster mode, both `key` and `new_key` must map to the same hash slot.
|
|
@@ -675,7 +761,9 @@ class CoreCommands(Protocol):
|
|
|
675
761
|
new_key (TEncodable): The new key name.
|
|
676
762
|
|
|
677
763
|
Returns:
|
|
678
|
-
bool: True if `key` was renamed to `new_key`,
|
|
764
|
+
bool: True if `key` was renamed to `new_key`,
|
|
765
|
+
|
|
766
|
+
False if `new_key` already exists.
|
|
679
767
|
|
|
680
768
|
Examples:
|
|
681
769
|
>>> await client.renamenx("old_key", "new_key")
|
|
@@ -689,7 +777,8 @@ class CoreCommands(Protocol):
|
|
|
689
777
|
async def delete(self, keys: List[TEncodable]) -> int:
|
|
690
778
|
"""
|
|
691
779
|
Delete one or more keys from the database. A key is ignored if it does not exist.
|
|
692
|
-
|
|
780
|
+
|
|
781
|
+
See [valkey.io](https://valkey.io/commands/del/) for details.
|
|
693
782
|
|
|
694
783
|
Note:
|
|
695
784
|
In cluster mode, if keys in `keys` map to different hash slots,
|
|
@@ -719,10 +808,11 @@ class CoreCommands(Protocol):
|
|
|
719
808
|
"""
|
|
720
809
|
Increments the number stored at `key` by one. If the key does not exist, it is set to 0 before performing the
|
|
721
810
|
operation.
|
|
722
|
-
|
|
811
|
+
|
|
812
|
+
See [valkey.io](https://valkey.io/commands/incr/) for more details.
|
|
723
813
|
|
|
724
814
|
Args:
|
|
725
|
-
|
|
815
|
+
key (TEncodable): The key to increment its value.
|
|
726
816
|
|
|
727
817
|
Returns:
|
|
728
818
|
int: The value of `key` after the increment.
|
|
@@ -737,11 +827,13 @@ class CoreCommands(Protocol):
|
|
|
737
827
|
async def incrby(self, key: TEncodable, amount: int) -> int:
|
|
738
828
|
"""
|
|
739
829
|
Increments the number stored at `key` by `amount`. If the key does not exist, it is set to 0 before performing
|
|
740
|
-
the operation.
|
|
830
|
+
the operation.
|
|
831
|
+
|
|
832
|
+
See [valkey.io](https://valkey.io/commands/incrby/) for more details.
|
|
741
833
|
|
|
742
834
|
Args:
|
|
743
|
-
|
|
744
|
-
|
|
835
|
+
key (TEncodable): The key to increment its value.
|
|
836
|
+
amount (int) : The amount to increment.
|
|
745
837
|
|
|
746
838
|
Returns:
|
|
747
839
|
int: The value of key after the increment.
|
|
@@ -760,11 +852,12 @@ class CoreCommands(Protocol):
|
|
|
760
852
|
Increment the string representing a floating point number stored at `key` by `amount`.
|
|
761
853
|
By using a negative increment value, the value stored at the `key` is decremented.
|
|
762
854
|
If the key does not exist, it is set to 0 before performing the operation.
|
|
763
|
-
|
|
855
|
+
|
|
856
|
+
See [valkey.io](https://valkey.io/commands/incrbyfloat/) for more details.
|
|
764
857
|
|
|
765
858
|
Args:
|
|
766
|
-
|
|
767
|
-
|
|
859
|
+
key (TEncodable): The key to increment its value.
|
|
860
|
+
amount (float) : The amount to increment.
|
|
768
861
|
|
|
769
862
|
Returns:
|
|
770
863
|
float: The value of key after the increment.
|
|
@@ -787,7 +880,7 @@ class CoreCommands(Protocol):
|
|
|
787
880
|
the string is padded with zero bytes to make `offset` fit. Creates the `key`
|
|
788
881
|
if it doesn't exist.
|
|
789
882
|
|
|
790
|
-
See https://valkey.io/commands/setrange for more details.
|
|
883
|
+
See [valkey.io](https://valkey.io/commands/setrange) for more details.
|
|
791
884
|
|
|
792
885
|
Args:
|
|
793
886
|
key (TEncodable): The key of the string to update.
|
|
@@ -812,7 +905,8 @@ class CoreCommands(Protocol):
|
|
|
812
905
|
async def mset(self, key_value_map: Mapping[TEncodable, TEncodable]) -> TOK:
|
|
813
906
|
"""
|
|
814
907
|
Set multiple keys to multiple values in a single atomic operation.
|
|
815
|
-
|
|
908
|
+
|
|
909
|
+
See [valkey.io](https://valkey.io/commands/mset/) for more details.
|
|
816
910
|
|
|
817
911
|
Note:
|
|
818
912
|
In cluster mode, if keys in `key_value_map` map to different hash slots,
|
|
@@ -846,10 +940,11 @@ class CoreCommands(Protocol):
|
|
|
846
940
|
Note:
|
|
847
941
|
When in cluster mode, all keys in `key_value_map` must map to the same hash slot.
|
|
848
942
|
|
|
849
|
-
See https://valkey.io/commands/msetnx/ for more details.
|
|
943
|
+
See [valkey.io](https://valkey.io/commands/msetnx/) for more details.
|
|
850
944
|
|
|
851
945
|
Args:
|
|
852
|
-
key_value_map (Mapping[TEncodable, TEncodable]): A key-value map consisting of keys and their respective values to
|
|
946
|
+
key_value_map (Mapping[TEncodable, TEncodable]): A key-value map consisting of keys and their respective values to
|
|
947
|
+
set.
|
|
853
948
|
|
|
854
949
|
Returns:
|
|
855
950
|
bool: True if all keys were set. False if no key was set.
|
|
@@ -871,7 +966,8 @@ class CoreCommands(Protocol):
|
|
|
871
966
|
async def mget(self, keys: List[TEncodable]) -> List[Optional[bytes]]:
|
|
872
967
|
"""
|
|
873
968
|
Retrieve the values of multiple keys.
|
|
874
|
-
|
|
969
|
+
|
|
970
|
+
See [valkey.io](https://valkey.io/commands/mget/) for more details.
|
|
875
971
|
|
|
876
972
|
Note:
|
|
877
973
|
In cluster mode, if keys in `keys` map to different hash slots,
|
|
@@ -881,6 +977,7 @@ class CoreCommands(Protocol):
|
|
|
881
977
|
though some requests may have succeeded while others did not.
|
|
882
978
|
If this behavior impacts your application logic, consider splitting the
|
|
883
979
|
request into sub-requests per slot to ensure atomicity.
|
|
980
|
+
|
|
884
981
|
Args:
|
|
885
982
|
keys (List[TEncodable]): A list of keys to retrieve values for.
|
|
886
983
|
|
|
@@ -902,10 +999,11 @@ class CoreCommands(Protocol):
|
|
|
902
999
|
"""
|
|
903
1000
|
Decrement the number stored at `key` by one. If the key does not exist, it is set to 0 before performing the
|
|
904
1001
|
operation.
|
|
905
|
-
|
|
1002
|
+
|
|
1003
|
+
See [valkey.io](https://valkey.io/commands/decr/) for more details.
|
|
906
1004
|
|
|
907
1005
|
Args:
|
|
908
|
-
|
|
1006
|
+
key (TEncodable): The key to increment its value.
|
|
909
1007
|
|
|
910
1008
|
Returns:
|
|
911
1009
|
int: The value of key after the decrement.
|
|
@@ -921,11 +1019,12 @@ class CoreCommands(Protocol):
|
|
|
921
1019
|
"""
|
|
922
1020
|
Decrements the number stored at `key` by `amount`. If the key does not exist, it is set to 0 before performing
|
|
923
1021
|
the operation.
|
|
924
|
-
|
|
1022
|
+
|
|
1023
|
+
See [valkey.io](https://valkey.io/commands/decrby/) for more details.
|
|
925
1024
|
|
|
926
1025
|
Args:
|
|
927
|
-
|
|
928
|
-
|
|
1026
|
+
key (TEncodable): The key to decrement its value.
|
|
1027
|
+
amount (int) : The amount to decrement.
|
|
929
1028
|
|
|
930
1029
|
Returns:
|
|
931
1030
|
int: The value of key after the decrement.
|
|
@@ -943,7 +1042,7 @@ class CoreCommands(Protocol):
|
|
|
943
1042
|
"""
|
|
944
1043
|
Updates the last access time of specified keys.
|
|
945
1044
|
|
|
946
|
-
See https://valkey.io/commands/touch/ for details.
|
|
1045
|
+
See [valkey.io](https://valkey.io/commands/touch/) for details.
|
|
947
1046
|
|
|
948
1047
|
Note:
|
|
949
1048
|
In cluster mode, if keys in `key_value_map` map to different hash slots,
|
|
@@ -952,8 +1051,7 @@ class CoreCommands(Protocol):
|
|
|
952
1051
|
requests fail, the entire call will return the first encountered error, even
|
|
953
1052
|
though some requests may have succeeded while others did not.
|
|
954
1053
|
If this behavior impacts your application logic, consider splitting the
|
|
955
|
-
request into sub-requests per slot to ensure atomicity.
|
|
956
|
-
keys (List[TEncodable]): The list of keys to unlink.
|
|
1054
|
+
request into sub-requests per slot to ensure atomicity.
|
|
957
1055
|
|
|
958
1056
|
Args:
|
|
959
1057
|
keys (List[TEncodable]): The keys to update last access time.
|
|
@@ -976,12 +1074,13 @@ class CoreCommands(Protocol):
|
|
|
976
1074
|
) -> int:
|
|
977
1075
|
"""
|
|
978
1076
|
Sets the specified fields to their respective values in the hash stored at `key`.
|
|
979
|
-
|
|
1077
|
+
|
|
1078
|
+
See [valkey.io](https://valkey.io/commands/hset/) for more details.
|
|
980
1079
|
|
|
981
1080
|
Args:
|
|
982
1081
|
key (TEncodable): The key of the hash.
|
|
983
|
-
field_value_map (Mapping[TEncodable, TEncodable]): A field-value map consisting of fields and their corresponding
|
|
984
|
-
|
|
1082
|
+
field_value_map (Mapping[TEncodable, TEncodable]): A field-value map consisting of fields and their corresponding
|
|
1083
|
+
values to be set in the hash stored at the specified key.
|
|
985
1084
|
|
|
986
1085
|
Returns:
|
|
987
1086
|
int: The number of fields that were added to the hash.
|
|
@@ -1001,7 +1100,8 @@ class CoreCommands(Protocol):
|
|
|
1001
1100
|
async def hget(self, key: TEncodable, field: TEncodable) -> Optional[bytes]:
|
|
1002
1101
|
"""
|
|
1003
1102
|
Retrieves the value associated with `field` in the hash stored at `key`.
|
|
1004
|
-
|
|
1103
|
+
|
|
1104
|
+
See [valkey.io](https://valkey.io/commands/hget/) for more details.
|
|
1005
1105
|
|
|
1006
1106
|
Args:
|
|
1007
1107
|
key (TEncodable): The key of the hash.
|
|
@@ -1009,6 +1109,7 @@ class CoreCommands(Protocol):
|
|
|
1009
1109
|
|
|
1010
1110
|
Returns:
|
|
1011
1111
|
Optional[bytes]: The value associated `field` in the hash.
|
|
1112
|
+
|
|
1012
1113
|
Returns None if `field` is not presented in the hash or `key` does not exist.
|
|
1013
1114
|
|
|
1014
1115
|
Examples:
|
|
@@ -1033,7 +1134,8 @@ class CoreCommands(Protocol):
|
|
|
1033
1134
|
Sets `field` in the hash stored at `key` to `value`, only if `field` does not yet exist.
|
|
1034
1135
|
If `key` does not exist, a new key holding a hash is created.
|
|
1035
1136
|
If `field` already exists, this operation has no effect.
|
|
1036
|
-
|
|
1137
|
+
|
|
1138
|
+
See [valkey.io](https://valkey.io/commands/hsetnx/) for more details.
|
|
1037
1139
|
|
|
1038
1140
|
Args:
|
|
1039
1141
|
key (TEncodable): The key of the hash.
|
|
@@ -1041,7 +1143,9 @@ class CoreCommands(Protocol):
|
|
|
1041
1143
|
value (TEncodable): The value to set.
|
|
1042
1144
|
|
|
1043
1145
|
Returns:
|
|
1044
|
-
bool: True if the field was set
|
|
1146
|
+
bool: True if the field was set.
|
|
1147
|
+
|
|
1148
|
+
False if the field already existed and was not set.
|
|
1045
1149
|
|
|
1046
1150
|
Examples:
|
|
1047
1151
|
>>> await client.hsetnx("my_hash", "field", "value")
|
|
@@ -1059,7 +1163,8 @@ class CoreCommands(Protocol):
|
|
|
1059
1163
|
Increment or decrement the value of a `field` in the hash stored at `key` by the specified amount.
|
|
1060
1164
|
By using a negative increment value, the value stored at `field` in the hash stored at `key` is decremented.
|
|
1061
1165
|
If `field` or `key` does not exist, it is set to 0 before performing the operation.
|
|
1062
|
-
|
|
1166
|
+
|
|
1167
|
+
See [valkey.io](https://valkey.io/commands/hincrby/) for more details.
|
|
1063
1168
|
|
|
1064
1169
|
Args:
|
|
1065
1170
|
key (TEncodable): The key of the hash.
|
|
@@ -1087,7 +1192,8 @@ class CoreCommands(Protocol):
|
|
|
1087
1192
|
amount.
|
|
1088
1193
|
By using a negative increment value, the value stored at `field` in the hash stored at `key` is decremented.
|
|
1089
1194
|
If `field` or `key` does not exist, it is set to 0 before performing the operation.
|
|
1090
|
-
|
|
1195
|
+
|
|
1196
|
+
See [valkey.io](https://valkey.io/commands/hincrbyfloat/) for more details.
|
|
1091
1197
|
|
|
1092
1198
|
Args:
|
|
1093
1199
|
key (TEncodable): The key of the hash.
|
|
@@ -1112,15 +1218,17 @@ class CoreCommands(Protocol):
|
|
|
1112
1218
|
async def hexists(self, key: TEncodable, field: TEncodable) -> bool:
|
|
1113
1219
|
"""
|
|
1114
1220
|
Check if a field exists in the hash stored at `key`.
|
|
1115
|
-
|
|
1221
|
+
|
|
1222
|
+
See [valkey.io](https://valkey.io/commands/hexists/) for more details.
|
|
1116
1223
|
|
|
1117
1224
|
Args:
|
|
1118
1225
|
key (TEncodable): The key of the hash.
|
|
1119
1226
|
field (TEncodable): The field to check in the hash stored at `key`.
|
|
1120
1227
|
|
|
1121
1228
|
Returns:
|
|
1122
|
-
bool:
|
|
1123
|
-
|
|
1229
|
+
bool: `True` if the hash contains the specified field.
|
|
1230
|
+
|
|
1231
|
+
`False` if the hash does not contain the field, or if the key does not exist.
|
|
1124
1232
|
|
|
1125
1233
|
Examples:
|
|
1126
1234
|
>>> await client.hexists("my_hash", "field1")
|
|
@@ -1135,14 +1243,16 @@ class CoreCommands(Protocol):
|
|
|
1135
1243
|
async def hgetall(self, key: TEncodable) -> Dict[bytes, bytes]:
|
|
1136
1244
|
"""
|
|
1137
1245
|
Returns all fields and values of the hash stored at `key`.
|
|
1138
|
-
|
|
1246
|
+
|
|
1247
|
+
See [valkey.io](https://valkey.io/commands/hgetall/) for details.
|
|
1139
1248
|
|
|
1140
1249
|
Args:
|
|
1141
1250
|
key (TEncodable): The key of the hash.
|
|
1142
1251
|
|
|
1143
1252
|
Returns:
|
|
1144
|
-
Dict[bytes, bytes]: A dictionary of fields and their values stored in the hash. Every field name in the list is
|
|
1145
|
-
its value.
|
|
1253
|
+
Dict[bytes, bytes]: A dictionary of fields and their values stored in the hash. Every field name in the list is
|
|
1254
|
+
followed by its value.
|
|
1255
|
+
|
|
1146
1256
|
If `key` does not exist, it returns an empty dictionary.
|
|
1147
1257
|
|
|
1148
1258
|
Examples:
|
|
@@ -1158,7 +1268,8 @@ class CoreCommands(Protocol):
|
|
|
1158
1268
|
) -> List[Optional[bytes]]:
|
|
1159
1269
|
"""
|
|
1160
1270
|
Retrieve the values associated with specified fields in the hash stored at `key`.
|
|
1161
|
-
|
|
1271
|
+
|
|
1272
|
+
See [valkey.io](https://valkey.io/commands/hmget/) for details.
|
|
1162
1273
|
|
|
1163
1274
|
Args:
|
|
1164
1275
|
key (TEncodable): The key of the hash.
|
|
@@ -1167,6 +1278,7 @@ class CoreCommands(Protocol):
|
|
|
1167
1278
|
Returns:
|
|
1168
1279
|
List[Optional[bytes]]: A list of values associated with the given fields, in the same order as they are requested.
|
|
1169
1280
|
For every field that does not exist in the hash, a null value is returned.
|
|
1281
|
+
|
|
1170
1282
|
If `key` does not exist, it is treated as an empty hash, and the function returns a list of null values.
|
|
1171
1283
|
|
|
1172
1284
|
Examples:
|
|
@@ -1181,7 +1293,8 @@ class CoreCommands(Protocol):
|
|
|
1181
1293
|
async def hdel(self, key: TEncodable, fields: List[TEncodable]) -> int:
|
|
1182
1294
|
"""
|
|
1183
1295
|
Remove specified fields from the hash stored at `key`.
|
|
1184
|
-
|
|
1296
|
+
|
|
1297
|
+
See [valkey.io](https://valkey.io/commands/hdel/) for more details.
|
|
1185
1298
|
|
|
1186
1299
|
Args:
|
|
1187
1300
|
key (TEncodable): The key of the hash.
|
|
@@ -1189,6 +1302,7 @@ class CoreCommands(Protocol):
|
|
|
1189
1302
|
|
|
1190
1303
|
Returns:
|
|
1191
1304
|
int: The number of fields that were removed from the hash, excluding specified but non-existing fields.
|
|
1305
|
+
|
|
1192
1306
|
If `key` does not exist, it is treated as an empty hash, and the function returns 0.
|
|
1193
1307
|
|
|
1194
1308
|
Examples:
|
|
@@ -1201,13 +1315,14 @@ class CoreCommands(Protocol):
|
|
|
1201
1315
|
"""
|
|
1202
1316
|
Returns the number of fields contained in the hash stored at `key`.
|
|
1203
1317
|
|
|
1204
|
-
See https://valkey.io/commands/hlen/ for more details.
|
|
1318
|
+
See [valkey.io](https://valkey.io/commands/hlen/) for more details.
|
|
1205
1319
|
|
|
1206
1320
|
Args:
|
|
1207
1321
|
key (TEncodable): The key of the hash.
|
|
1208
1322
|
|
|
1209
1323
|
Returns:
|
|
1210
1324
|
int: The number of fields in the hash, or 0 when the key does not exist.
|
|
1325
|
+
|
|
1211
1326
|
If `key` holds a value that is not a hash, an error is returned.
|
|
1212
1327
|
|
|
1213
1328
|
Examples:
|
|
@@ -1222,7 +1337,7 @@ class CoreCommands(Protocol):
|
|
|
1222
1337
|
"""
|
|
1223
1338
|
Returns all values in the hash stored at `key`.
|
|
1224
1339
|
|
|
1225
|
-
See https://valkey.io/commands/hvals/ for more details.
|
|
1340
|
+
See [valkey.io](https://valkey.io/commands/hvals/) for more details.
|
|
1226
1341
|
|
|
1227
1342
|
Args:
|
|
1228
1343
|
key (TEncodable): The key of the hash.
|
|
@@ -1240,7 +1355,7 @@ class CoreCommands(Protocol):
|
|
|
1240
1355
|
"""
|
|
1241
1356
|
Returns all field names in the hash stored at `key`.
|
|
1242
1357
|
|
|
1243
|
-
See https://valkey.io/commands/hkeys/ for more details.
|
|
1358
|
+
See [valkey.io](https://valkey.io/commands/hkeys/) for more details.
|
|
1244
1359
|
|
|
1245
1360
|
Args:
|
|
1246
1361
|
key (TEncodable): The key of the hash.
|
|
@@ -1258,13 +1373,14 @@ class CoreCommands(Protocol):
|
|
|
1258
1373
|
"""
|
|
1259
1374
|
Returns a random field name from the hash value stored at `key`.
|
|
1260
1375
|
|
|
1261
|
-
See https://valkey.io/commands/hrandfield for more details.
|
|
1376
|
+
See [valkey.io](https://valkey.io/commands/hrandfield) for more details.
|
|
1262
1377
|
|
|
1263
1378
|
Args:
|
|
1264
1379
|
key (TEncodable): The key of the hash.
|
|
1265
1380
|
|
|
1266
1381
|
Returns:
|
|
1267
1382
|
Optional[bytes]: A random field name from the hash stored at `key`.
|
|
1383
|
+
|
|
1268
1384
|
If the hash does not exist or is empty, None will be returned.
|
|
1269
1385
|
|
|
1270
1386
|
Examples:
|
|
@@ -1279,16 +1395,18 @@ class CoreCommands(Protocol):
|
|
|
1279
1395
|
"""
|
|
1280
1396
|
Retrieves up to `count` random field names from the hash value stored at `key`.
|
|
1281
1397
|
|
|
1282
|
-
See https://valkey.io/commands/hrandfield for more details.
|
|
1398
|
+
See [valkey.io](https://valkey.io/commands/hrandfield) for more details.
|
|
1283
1399
|
|
|
1284
1400
|
Args:
|
|
1285
1401
|
key (TEncodable): The key of the hash.
|
|
1286
1402
|
count (int): The number of field names to return.
|
|
1287
|
-
|
|
1288
|
-
If `count` is
|
|
1403
|
+
|
|
1404
|
+
- If `count` is positive, returns unique elements.
|
|
1405
|
+
- If `count` is negative, allows for duplicates elements.
|
|
1289
1406
|
|
|
1290
1407
|
Returns:
|
|
1291
1408
|
List[bytes]: A list of random field names from the hash.
|
|
1409
|
+
|
|
1292
1410
|
If the hash does not exist or is empty, the response will be an empty list.
|
|
1293
1411
|
|
|
1294
1412
|
Examples:
|
|
@@ -1308,17 +1426,19 @@ class CoreCommands(Protocol):
|
|
|
1308
1426
|
"""
|
|
1309
1427
|
Retrieves up to `count` random field names along with their values from the hash value stored at `key`.
|
|
1310
1428
|
|
|
1311
|
-
See https://valkey.io/commands/hrandfield for more details.
|
|
1429
|
+
See [valkey.io](https://valkey.io/commands/hrandfield) for more details.
|
|
1312
1430
|
|
|
1313
1431
|
Args:
|
|
1314
1432
|
key (TEncodable): The key of the hash.
|
|
1315
1433
|
count (int): The number of field names to return.
|
|
1316
|
-
|
|
1317
|
-
If `count` is
|
|
1434
|
+
|
|
1435
|
+
- If `count` is positive, returns unique elements.
|
|
1436
|
+
- If `count` is negative, allows for duplicates elements.
|
|
1318
1437
|
|
|
1319
1438
|
Returns:
|
|
1320
1439
|
List[List[bytes]]: A list of `[field_name, value]` lists, where `field_name` is a random field name from the
|
|
1321
1440
|
hash and `value` is the associated value of the field name.
|
|
1441
|
+
|
|
1322
1442
|
If the hash does not exist or is empty, the response will be an empty list.
|
|
1323
1443
|
|
|
1324
1444
|
Examples:
|
|
@@ -1336,14 +1456,16 @@ class CoreCommands(Protocol):
|
|
|
1336
1456
|
"""
|
|
1337
1457
|
Returns the string length of the value associated with `field` in the hash stored at `key`.
|
|
1338
1458
|
|
|
1339
|
-
See https://valkey.io/commands/hstrlen/ for more details.
|
|
1459
|
+
See [valkey.io](https://valkey.io/commands/hstrlen/) for more details.
|
|
1340
1460
|
|
|
1341
1461
|
Args:
|
|
1342
1462
|
key (TEncodable): The key of the hash.
|
|
1343
1463
|
field (TEncodable): The field in the hash.
|
|
1344
1464
|
|
|
1345
1465
|
Returns:
|
|
1346
|
-
int: The string length
|
|
1466
|
+
int: The string length
|
|
1467
|
+
|
|
1468
|
+
0 if `field` or `key` does not exist.
|
|
1347
1469
|
|
|
1348
1470
|
Examples:
|
|
1349
1471
|
>>> await client.hset("my_hash", "field", "value")
|
|
@@ -1360,7 +1482,8 @@ class CoreCommands(Protocol):
|
|
|
1360
1482
|
Insert all the specified values at the head of the list stored at `key`.
|
|
1361
1483
|
`elements` are inserted one after the other to the head of the list, from the leftmost element
|
|
1362
1484
|
to the rightmost element. If `key` does not exist, it is created as empty list before performing the push operations.
|
|
1363
|
-
|
|
1485
|
+
|
|
1486
|
+
See [valkey.io](https://valkey.io/commands/lpush/) for more details.
|
|
1364
1487
|
|
|
1365
1488
|
Args:
|
|
1366
1489
|
key (TEncodable): The key of the list.
|
|
@@ -1384,7 +1507,7 @@ class CoreCommands(Protocol):
|
|
|
1384
1507
|
Inserts all the specified values at the head of the list stored at `key`, only if `key` exists and holds a list.
|
|
1385
1508
|
If `key` is not a list, this performs no operation.
|
|
1386
1509
|
|
|
1387
|
-
See https://valkey.io/commands/lpushx/ for more details.
|
|
1510
|
+
See [valkey.io](https://valkey.io/commands/lpushx/) for more details.
|
|
1388
1511
|
|
|
1389
1512
|
Args:
|
|
1390
1513
|
key (TEncodable): The key of the list.
|
|
@@ -1407,13 +1530,15 @@ class CoreCommands(Protocol):
|
|
|
1407
1530
|
"""
|
|
1408
1531
|
Remove and return the first elements of the list stored at `key`.
|
|
1409
1532
|
The command pops a single element from the beginning of the list.
|
|
1410
|
-
|
|
1533
|
+
|
|
1534
|
+
See [valkey.io](https://valkey.io/commands/lpop/) for details.
|
|
1411
1535
|
|
|
1412
1536
|
Args:
|
|
1413
1537
|
key (TEncodable): The key of the list.
|
|
1414
1538
|
|
|
1415
1539
|
Returns:
|
|
1416
1540
|
Optional[bytes]: The value of the first element.
|
|
1541
|
+
|
|
1417
1542
|
If `key` does not exist, None will be returned.
|
|
1418
1543
|
|
|
1419
1544
|
Examples:
|
|
@@ -1430,7 +1555,8 @@ class CoreCommands(Protocol):
|
|
|
1430
1555
|
async def lpop_count(self, key: TEncodable, count: int) -> Optional[List[bytes]]:
|
|
1431
1556
|
"""
|
|
1432
1557
|
Remove and return up to `count` elements from the list stored at `key`, depending on the list's length.
|
|
1433
|
-
|
|
1558
|
+
|
|
1559
|
+
See [valkey.io](https://valkey.io/commands/lpop/) for details.
|
|
1434
1560
|
|
|
1435
1561
|
Args:
|
|
1436
1562
|
key (TEncodable): The key of the list.
|
|
@@ -1438,6 +1564,7 @@ class CoreCommands(Protocol):
|
|
|
1438
1564
|
|
|
1439
1565
|
Returns:
|
|
1440
1566
|
Optional[List[bytes]]: A a list of popped elements will be returned depending on the list's length.
|
|
1567
|
+
|
|
1441
1568
|
If `key` does not exist, None will be returned.
|
|
1442
1569
|
|
|
1443
1570
|
Examples:
|
|
@@ -1457,19 +1584,25 @@ class CoreCommands(Protocol):
|
|
|
1457
1584
|
"""
|
|
1458
1585
|
Pops an element from the head of the first list that is non-empty, with the given keys being checked in the
|
|
1459
1586
|
order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.
|
|
1460
|
-
See https://valkey.io/commands/blpop for details.
|
|
1461
1587
|
|
|
1462
|
-
|
|
1588
|
+
See [valkey.io](https://valkey.io/commands/blpop) for details.
|
|
1589
|
+
|
|
1590
|
+
Note:
|
|
1463
1591
|
1. When in cluster mode, all `keys` must map to the same hash slot.
|
|
1464
|
-
2. `BLPOP` is a client blocking command, see
|
|
1592
|
+
2. `BLPOP` is a client blocking command, see
|
|
1593
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
1594
|
+
for more details and best practices.
|
|
1465
1595
|
|
|
1466
1596
|
Args:
|
|
1467
1597
|
keys (List[TEncodable]): The keys of the lists to pop from.
|
|
1468
|
-
timeout (float): The number of seconds to wait for a blocking operation to complete.
|
|
1598
|
+
timeout (float): The number of seconds to wait for a blocking operation to complete.
|
|
1599
|
+
A value of 0 will block indefinitely.
|
|
1469
1600
|
|
|
1470
1601
|
Returns:
|
|
1471
1602
|
Optional[List[bytes]]: A two-element list containing the key from which the element was popped and the value of the
|
|
1472
|
-
|
|
1603
|
+
popped element, formatted as `[key, value]`.
|
|
1604
|
+
|
|
1605
|
+
If no element could be popped and the `timeout` expired, returns None.
|
|
1473
1606
|
|
|
1474
1607
|
Examples:
|
|
1475
1608
|
>>> await client.blpop(["list1", "list2"], 0.5)
|
|
@@ -1491,15 +1624,19 @@ class CoreCommands(Protocol):
|
|
|
1491
1624
|
|
|
1492
1625
|
When in cluster mode, all `keys` must map to the same hash slot.
|
|
1493
1626
|
|
|
1494
|
-
See https://valkey.io/commands/lmpop/ for details.
|
|
1627
|
+
See [valkey.io](https://valkey.io/commands/lmpop/) for details.
|
|
1495
1628
|
|
|
1496
1629
|
Args:
|
|
1497
1630
|
keys (List[TEncodable]): An array of keys of lists.
|
|
1498
|
-
direction (ListDirection): The direction based on which elements are popped from
|
|
1499
|
-
|
|
1631
|
+
direction (ListDirection): The direction based on which elements are popped from
|
|
1632
|
+
(`ListDirection.LEFT` or `ListDirection.RIGHT`).
|
|
1633
|
+
count (Optional[int]): The maximum number of popped elements. If not provided, defaults to popping a
|
|
1634
|
+
single element.
|
|
1500
1635
|
|
|
1501
1636
|
Returns:
|
|
1502
|
-
Optional[Mapping[bytes, List[bytes]]]: A map of `key` name mapped to an array of popped elements,
|
|
1637
|
+
Optional[Mapping[bytes, List[bytes]]]: A `map` of `key` name mapped to an array of popped elements,
|
|
1638
|
+
|
|
1639
|
+
`None` if no elements could be popped.
|
|
1503
1640
|
|
|
1504
1641
|
Examples:
|
|
1505
1642
|
>>> await client.lpush("testKey", ["one", "two", "three"])
|
|
@@ -1529,20 +1666,27 @@ class CoreCommands(Protocol):
|
|
|
1529
1666
|
|
|
1530
1667
|
`BLMPOP` is the blocking variant of `LMPOP`.
|
|
1531
1668
|
|
|
1532
|
-
|
|
1669
|
+
Note:
|
|
1533
1670
|
1. When in cluster mode, all `keys` must map to the same hash slot.
|
|
1534
|
-
2. `BLMPOP` is a client blocking command, see
|
|
1671
|
+
2. `BLMPOP` is a client blocking command, see
|
|
1672
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
1673
|
+
for more details and best practices.
|
|
1535
1674
|
|
|
1536
|
-
See https://valkey.io/commands/blmpop/ for details.
|
|
1675
|
+
See [valkey.io](https://valkey.io/commands/blmpop/) for details.
|
|
1537
1676
|
|
|
1538
1677
|
Args:
|
|
1539
1678
|
keys (List[TEncodable]): An array of keys of lists.
|
|
1540
|
-
direction (ListDirection): The direction based on which elements are popped from
|
|
1541
|
-
|
|
1542
|
-
|
|
1679
|
+
direction (ListDirection): The direction based on which elements are popped from
|
|
1680
|
+
(`ListDirection.LEFT` or `ListDirection.RIGHT`).
|
|
1681
|
+
timeout (float): The number of seconds to wait for a blocking operation to complete.
|
|
1682
|
+
A value of `0` will block indefinitely.
|
|
1683
|
+
count (Optional[int]): The maximum number of popped elements. If not provided, defaults to popping a single
|
|
1684
|
+
element.
|
|
1543
1685
|
|
|
1544
1686
|
Returns:
|
|
1545
|
-
Optional[Mapping[bytes, List[bytes]]]: A map of `key` name mapped to an array of popped elements
|
|
1687
|
+
Optional[Mapping[bytes, List[bytes]]]: A `map` of `key` name mapped to an array of popped elements.
|
|
1688
|
+
|
|
1689
|
+
`None` if no elements could be popped and the timeout expired.
|
|
1546
1690
|
|
|
1547
1691
|
Examples:
|
|
1548
1692
|
>>> await client.lpush("testKey", ["one", "two", "three"])
|
|
@@ -1566,7 +1710,8 @@ class CoreCommands(Protocol):
|
|
|
1566
1710
|
The offsets `start` and `end` are zero-based indexes, with 0 being the first element of the list, 1 being the next
|
|
1567
1711
|
element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list,
|
|
1568
1712
|
with -1 being the last element of the list, -2 being the penultimate, and so on.
|
|
1569
|
-
|
|
1713
|
+
|
|
1714
|
+
See [valkey.io](https://valkey.io/commands/lrange/) for details.
|
|
1570
1715
|
|
|
1571
1716
|
Args:
|
|
1572
1717
|
key (TEncodable): The key of the list.
|
|
@@ -1575,8 +1720,11 @@ class CoreCommands(Protocol):
|
|
|
1575
1720
|
|
|
1576
1721
|
Returns:
|
|
1577
1722
|
List[bytes]: A list of elements within the specified range.
|
|
1723
|
+
|
|
1578
1724
|
If `start` exceeds the `end` of the list, or if `start` is greater than `end`, an empty list will be returned.
|
|
1725
|
+
|
|
1579
1726
|
If `end` exceeds the actual end of the list, the range will stop at the actual end of the list.
|
|
1727
|
+
|
|
1580
1728
|
If `key` does not exist an empty list will be returned.
|
|
1581
1729
|
|
|
1582
1730
|
Examples:
|
|
@@ -1606,7 +1754,7 @@ class CoreCommands(Protocol):
|
|
|
1606
1754
|
Negative indices can be used to designate elements starting at the tail of the list.
|
|
1607
1755
|
Here, -1 means the last element, -2 means the penultimate and so forth.
|
|
1608
1756
|
|
|
1609
|
-
See https://valkey.io/commands/lindex/ for more details.
|
|
1757
|
+
See [valkey.io](https://valkey.io/commands/lindex/) for more details.
|
|
1610
1758
|
|
|
1611
1759
|
Args:
|
|
1612
1760
|
key (TEncodable): The key of the list.
|
|
@@ -1614,7 +1762,8 @@ class CoreCommands(Protocol):
|
|
|
1614
1762
|
|
|
1615
1763
|
Returns:
|
|
1616
1764
|
Optional[bytes]: The element at `index` in the list stored at `key`.
|
|
1617
|
-
|
|
1765
|
+
|
|
1766
|
+
If `index` is out of range or if `key` does not exist, None is returned.
|
|
1618
1767
|
|
|
1619
1768
|
Examples:
|
|
1620
1769
|
>>> await client.lindex("my_list", 0)
|
|
@@ -1635,7 +1784,7 @@ class CoreCommands(Protocol):
|
|
|
1635
1784
|
Negative indices can be used to designate elements starting at the tail of the list.
|
|
1636
1785
|
Here, `-1` means the last element, `-2` means the penultimate and so forth.
|
|
1637
1786
|
|
|
1638
|
-
See https://valkey.io/commands/lset/ for details.
|
|
1787
|
+
See [valkey.io](https://valkey.io/commands/lset/) for details.
|
|
1639
1788
|
|
|
1640
1789
|
Args:
|
|
1641
1790
|
key (TEncodable): The key of the list.
|
|
@@ -1659,7 +1808,8 @@ class CoreCommands(Protocol):
|
|
|
1659
1808
|
Inserts all the specified values at the tail of the list stored at `key`.
|
|
1660
1809
|
`elements` are inserted one after the other to the tail of the list, from the leftmost element
|
|
1661
1810
|
to the rightmost element. If `key` does not exist, it is created as empty list before performing the push operations.
|
|
1662
|
-
|
|
1811
|
+
|
|
1812
|
+
See [valkey.io](https://valkey.io/commands/rpush/) for more details.
|
|
1663
1813
|
|
|
1664
1814
|
Args:
|
|
1665
1815
|
key (TEncodable): The key of the list.
|
|
@@ -1683,7 +1833,7 @@ class CoreCommands(Protocol):
|
|
|
1683
1833
|
Inserts all the specified values at the tail of the list stored at `key`, only if `key` exists and holds a list.
|
|
1684
1834
|
If `key` is not a list, this performs no operation.
|
|
1685
1835
|
|
|
1686
|
-
See https://valkey.io/commands/rpushx/ for more details.
|
|
1836
|
+
See [valkey.io](https://valkey.io/commands/rpushx/) for more details.
|
|
1687
1837
|
|
|
1688
1838
|
Args:
|
|
1689
1839
|
key (TEncodable): The key of the list.
|
|
@@ -1706,13 +1856,15 @@ class CoreCommands(Protocol):
|
|
|
1706
1856
|
"""
|
|
1707
1857
|
Removes and returns the last elements of the list stored at `key`.
|
|
1708
1858
|
The command pops a single element from the end of the list.
|
|
1709
|
-
|
|
1859
|
+
|
|
1860
|
+
See [valkey.io](https://valkey.io/commands/rpop/) for details.
|
|
1710
1861
|
|
|
1711
1862
|
Args:
|
|
1712
1863
|
key (TEncodable): The key of the list.
|
|
1713
1864
|
|
|
1714
1865
|
Returns:
|
|
1715
1866
|
Optional[bytes]: The value of the last element.
|
|
1867
|
+
|
|
1716
1868
|
If `key` does not exist, None will be returned.
|
|
1717
1869
|
|
|
1718
1870
|
Examples:
|
|
@@ -1729,7 +1881,8 @@ class CoreCommands(Protocol):
|
|
|
1729
1881
|
async def rpop_count(self, key: TEncodable, count: int) -> Optional[List[bytes]]:
|
|
1730
1882
|
"""
|
|
1731
1883
|
Removes and returns up to `count` elements from the list stored at `key`, depending on the list's length.
|
|
1732
|
-
|
|
1884
|
+
|
|
1885
|
+
See [valkey.io](https://valkey.io/commands/rpop/) for details.
|
|
1733
1886
|
|
|
1734
1887
|
Args:
|
|
1735
1888
|
key (TEncodable): The key of the list.
|
|
@@ -1737,6 +1890,7 @@ class CoreCommands(Protocol):
|
|
|
1737
1890
|
|
|
1738
1891
|
Returns:
|
|
1739
1892
|
Optional[List[bytes]: A list of popped elements will be returned depending on the list's length.
|
|
1893
|
+
|
|
1740
1894
|
If `key` does not exist, None will be returned.
|
|
1741
1895
|
|
|
1742
1896
|
Examples:
|
|
@@ -1756,19 +1910,25 @@ class CoreCommands(Protocol):
|
|
|
1756
1910
|
"""
|
|
1757
1911
|
Pops an element from the tail of the first list that is non-empty, with the given keys being checked in the
|
|
1758
1912
|
order that they are given. Blocks the connection when there are no elements to pop from any of the given lists.
|
|
1759
|
-
|
|
1913
|
+
|
|
1914
|
+
See [valkey.io](https://valkey.io/commands/brpop) for details.
|
|
1760
1915
|
|
|
1761
1916
|
Notes:
|
|
1762
1917
|
1. When in cluster mode, all `keys` must map to the same hash slot.
|
|
1763
|
-
2. `BRPOP` is a client blocking command, see
|
|
1918
|
+
2. `BRPOP` is a client blocking command, see
|
|
1919
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
1920
|
+
for more details and best practices.
|
|
1764
1921
|
|
|
1765
1922
|
Args:
|
|
1766
1923
|
keys (List[TEncodable]): The keys of the lists to pop from.
|
|
1767
|
-
timeout (float): The number of seconds to wait for a blocking operation to complete.
|
|
1924
|
+
timeout (float): The number of seconds to wait for a blocking operation to complete.
|
|
1925
|
+
A value of 0 will block indefinitely.
|
|
1768
1926
|
|
|
1769
1927
|
Returns:
|
|
1770
1928
|
Optional[List[bytes]]: A two-element list containing the key from which the element was popped and the value of the
|
|
1771
|
-
|
|
1929
|
+
popped element, formatted as `[key, value]`.
|
|
1930
|
+
|
|
1931
|
+
If no element could be popped and the `timeout` expired, returns None.
|
|
1772
1932
|
|
|
1773
1933
|
Examples:
|
|
1774
1934
|
>>> await client.brpop(["list1", "list2"], 0.5)
|
|
@@ -1789,7 +1949,7 @@ class CoreCommands(Protocol):
|
|
|
1789
1949
|
"""
|
|
1790
1950
|
Inserts `element` in the list at `key` either before or after the `pivot`.
|
|
1791
1951
|
|
|
1792
|
-
See https://valkey.io/commands/linsert/ for details.
|
|
1952
|
+
See [valkey.io](https://valkey.io/commands/linsert/) for details.
|
|
1793
1953
|
|
|
1794
1954
|
Args:
|
|
1795
1955
|
key (TEncodable): The key of the list.
|
|
@@ -1800,8 +1960,10 @@ class CoreCommands(Protocol):
|
|
|
1800
1960
|
|
|
1801
1961
|
Returns:
|
|
1802
1962
|
int: The list length after a successful insert operation.
|
|
1803
|
-
|
|
1804
|
-
|
|
1963
|
+
|
|
1964
|
+
If the `key` doesn't exist returns `-1`.
|
|
1965
|
+
|
|
1966
|
+
If the `pivot` wasn't found, returns `0`.
|
|
1805
1967
|
|
|
1806
1968
|
Examples:
|
|
1807
1969
|
>>> await client.linsert("my_list", InsertPosition.BEFORE, "World", "There")
|
|
@@ -1828,16 +1990,20 @@ class CoreCommands(Protocol):
|
|
|
1828
1990
|
|
|
1829
1991
|
When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
1830
1992
|
|
|
1831
|
-
See https://valkey.io/commands/lmove/ for details.
|
|
1993
|
+
See [valkey.io](https://valkey.io/commands/lmove/) for details.
|
|
1832
1994
|
|
|
1833
1995
|
Args:
|
|
1834
1996
|
source (TEncodable): The key to the source list.
|
|
1835
1997
|
destination (TEncodable): The key to the destination list.
|
|
1836
|
-
where_from (ListDirection): The direction to remove the element from
|
|
1837
|
-
|
|
1998
|
+
where_from (ListDirection): The direction to remove the element from
|
|
1999
|
+
(`ListDirection.LEFT` or `ListDirection.RIGHT`).
|
|
2000
|
+
where_to (ListDirection): The direction to add the element to
|
|
2001
|
+
(`ListDirection.LEFT` or `ListDirection.RIGHT`).
|
|
1838
2002
|
|
|
1839
2003
|
Returns:
|
|
1840
|
-
Optional[bytes]: The popped element
|
|
2004
|
+
Optional[bytes]: The popped element.
|
|
2005
|
+
|
|
2006
|
+
`None` if `source` does not exist.
|
|
1841
2007
|
|
|
1842
2008
|
Examples:
|
|
1843
2009
|
>>> client.lpush("testKey1", ["two", "one"])
|
|
@@ -1875,19 +2041,26 @@ class CoreCommands(Protocol):
|
|
|
1875
2041
|
|
|
1876
2042
|
Notes:
|
|
1877
2043
|
1. When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
1878
|
-
2. `BLMOVE` is a client blocking command, see
|
|
2044
|
+
2. `BLMOVE` is a client blocking command, see
|
|
2045
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
2046
|
+
for more details and best practices.
|
|
1879
2047
|
|
|
1880
|
-
See https://valkey.io/commands/blmove/ for details.
|
|
2048
|
+
See [valkey.io](https://valkey.io/commands/blmove/) for details.
|
|
1881
2049
|
|
|
1882
2050
|
Args:
|
|
1883
2051
|
source (TEncodable): The key to the source list.
|
|
1884
2052
|
destination (TEncodable): The key to the destination list.
|
|
1885
|
-
where_from (ListDirection): The direction to remove the element from
|
|
1886
|
-
|
|
1887
|
-
|
|
2053
|
+
where_from (ListDirection): The direction to remove the element from
|
|
2054
|
+
(`ListDirection.LEFT` or `ListDirection.RIGHT`).
|
|
2055
|
+
where_to (ListDirection): The direction to add the element to
|
|
2056
|
+
(`ListDirection.LEFT` or `ListDirection.RIGHT`).
|
|
2057
|
+
timeout (float): The number of seconds to wait for a blocking operation to complete.
|
|
2058
|
+
A value of `0` will block indefinitely.
|
|
1888
2059
|
|
|
1889
2060
|
Returns:
|
|
1890
|
-
Optional[bytes]: The popped element
|
|
2061
|
+
Optional[bytes]: The popped element.
|
|
2062
|
+
|
|
2063
|
+
`None` if `source` does not exist or if the operation timed-out.
|
|
1891
2064
|
|
|
1892
2065
|
Examples:
|
|
1893
2066
|
>>> await client.lpush("testKey1", ["two", "one"])
|
|
@@ -1914,7 +2087,8 @@ class CoreCommands(Protocol):
|
|
|
1914
2087
|
Add specified members to the set stored at `key`.
|
|
1915
2088
|
Specified members that are already a member of this set are ignored.
|
|
1916
2089
|
If `key` does not exist, a new set is created before adding `members`.
|
|
1917
|
-
|
|
2090
|
+
|
|
2091
|
+
See [valkey.io](https://valkey.io/commands/sadd/) for more details.
|
|
1918
2092
|
|
|
1919
2093
|
Args:
|
|
1920
2094
|
key (TEncodable): The key where members will be added to its set.
|
|
@@ -1933,7 +2107,8 @@ class CoreCommands(Protocol):
|
|
|
1933
2107
|
"""
|
|
1934
2108
|
Remove specified members from the set stored at `key`.
|
|
1935
2109
|
Specified members that are not a member of this set are ignored.
|
|
1936
|
-
|
|
2110
|
+
|
|
2111
|
+
See [valkey.io](https://valkey.io/commands/srem/) for details.
|
|
1937
2112
|
|
|
1938
2113
|
Args:
|
|
1939
2114
|
key (TEncodable): The key from which members will be removed.
|
|
@@ -1941,7 +2116,8 @@ class CoreCommands(Protocol):
|
|
|
1941
2116
|
|
|
1942
2117
|
Returns:
|
|
1943
2118
|
int: The number of members that were removed from the set, excluding non-existing members.
|
|
1944
|
-
|
|
2119
|
+
|
|
2120
|
+
If `key` does not exist, it is treated as an empty set and this command returns 0.
|
|
1945
2121
|
|
|
1946
2122
|
Examples:
|
|
1947
2123
|
>>> await client.srem("my_set", ["member1", "member2"])
|
|
@@ -1952,14 +2128,16 @@ class CoreCommands(Protocol):
|
|
|
1952
2128
|
async def smembers(self, key: TEncodable) -> Set[bytes]:
|
|
1953
2129
|
"""
|
|
1954
2130
|
Retrieve all the members of the set value stored at `key`.
|
|
1955
|
-
|
|
2131
|
+
|
|
2132
|
+
See [valkey.io](https://valkey.io/commands/smembers/) for details.
|
|
1956
2133
|
|
|
1957
2134
|
Args:
|
|
1958
2135
|
key (TEncodable): The key from which to retrieve the set members.
|
|
1959
2136
|
|
|
1960
2137
|
Returns:
|
|
1961
2138
|
Set[bytes]: A set of all members of the set.
|
|
1962
|
-
|
|
2139
|
+
|
|
2140
|
+
If `key` does not exist an empty set will be returned.
|
|
1963
2141
|
|
|
1964
2142
|
Examples:
|
|
1965
2143
|
>>> await client.smembers("my_set")
|
|
@@ -1972,13 +2150,16 @@ class CoreCommands(Protocol):
|
|
|
1972
2150
|
async def scard(self, key: TEncodable) -> int:
|
|
1973
2151
|
"""
|
|
1974
2152
|
Retrieve the set cardinality (number of elements) of the set stored at `key`.
|
|
1975
|
-
|
|
2153
|
+
|
|
2154
|
+
See [valkey.io](https://valkey.io/commands/scard/) for details.
|
|
1976
2155
|
|
|
1977
2156
|
Args:
|
|
1978
2157
|
key (TEncodable): The key from which to retrieve the number of set members.
|
|
1979
2158
|
|
|
1980
2159
|
Returns:
|
|
1981
|
-
int: The cardinality (number of elements) of the set
|
|
2160
|
+
int: The cardinality (number of elements) of the set.
|
|
2161
|
+
|
|
2162
|
+
0 if the key does not exist.
|
|
1982
2163
|
|
|
1983
2164
|
Examples:
|
|
1984
2165
|
>>> await client.scard("my_set")
|
|
@@ -1990,7 +2171,8 @@ class CoreCommands(Protocol):
|
|
|
1990
2171
|
"""
|
|
1991
2172
|
Removes and returns one random member from the set stored at `key`.
|
|
1992
2173
|
|
|
1993
|
-
See https://valkey-io.github.io/commands/spop/ for more details.
|
|
2174
|
+
See [valkey.io](https://valkey-io.github.io/commands/spop/) for more details.
|
|
2175
|
+
|
|
1994
2176
|
To pop multiple members, see `spop_count`.
|
|
1995
2177
|
|
|
1996
2178
|
Args:
|
|
@@ -1998,6 +2180,7 @@ class CoreCommands(Protocol):
|
|
|
1998
2180
|
|
|
1999
2181
|
Returns:
|
|
2000
2182
|
Optional[bytes]: The value of the popped member.
|
|
2183
|
+
|
|
2001
2184
|
If `key` does not exist, None will be returned.
|
|
2002
2185
|
|
|
2003
2186
|
Examples:
|
|
@@ -2014,7 +2197,8 @@ class CoreCommands(Protocol):
|
|
|
2014
2197
|
"""
|
|
2015
2198
|
Removes and returns up to `count` random members from the set stored at `key`, depending on the set's length.
|
|
2016
2199
|
|
|
2017
|
-
See https://valkey-io.github.io/commands/spop/ for more details.
|
|
2200
|
+
See [valkey.io](https://valkey-io.github.io/commands/spop/) for more details.
|
|
2201
|
+
|
|
2018
2202
|
To pop a single member, see `spop`.
|
|
2019
2203
|
|
|
2020
2204
|
Args:
|
|
@@ -2023,7 +2207,8 @@ class CoreCommands(Protocol):
|
|
|
2023
2207
|
|
|
2024
2208
|
Returns:
|
|
2025
2209
|
Set[bytes]: A set of popped elements will be returned depending on the set's length.
|
|
2026
|
-
|
|
2210
|
+
|
|
2211
|
+
If `key` does not exist, an empty set will be returned.
|
|
2027
2212
|
|
|
2028
2213
|
Examples:
|
|
2029
2214
|
>>> await client.spop_count("my_set", 2)
|
|
@@ -2043,7 +2228,7 @@ class CoreCommands(Protocol):
|
|
|
2043
2228
|
"""
|
|
2044
2229
|
Returns if `member` is a member of the set stored at `key`.
|
|
2045
2230
|
|
|
2046
|
-
See https://valkey.io/commands/sismember/ for more details.
|
|
2231
|
+
See [valkey.io](https://valkey.io/commands/sismember/) for more details.
|
|
2047
2232
|
|
|
2048
2233
|
Args:
|
|
2049
2234
|
key (TEncodable): The key of the set.
|
|
@@ -2051,6 +2236,7 @@ class CoreCommands(Protocol):
|
|
|
2051
2236
|
|
|
2052
2237
|
Returns:
|
|
2053
2238
|
bool: True if the member exists in the set, False otherwise.
|
|
2239
|
+
|
|
2054
2240
|
If `key` doesn't exist, it is treated as an empty set and the command returns False.
|
|
2055
2241
|
|
|
2056
2242
|
Examples:
|
|
@@ -2074,7 +2260,7 @@ class CoreCommands(Protocol):
|
|
|
2074
2260
|
Moves `member` from the set at `source` to the set at `destination`, removing it from the source set. Creates a
|
|
2075
2261
|
new destination set if needed. The operation is atomic.
|
|
2076
2262
|
|
|
2077
|
-
See https://valkey.io/commands/smove for more details.
|
|
2263
|
+
See [valkey.io](https://valkey.io/commands/smove) for more details.
|
|
2078
2264
|
|
|
2079
2265
|
Note:
|
|
2080
2266
|
When in cluster mode, `source` and `destination` must map to the same hash slot.
|
|
@@ -2085,7 +2271,9 @@ class CoreCommands(Protocol):
|
|
|
2085
2271
|
member (TEncodable): The set element to move.
|
|
2086
2272
|
|
|
2087
2273
|
Returns:
|
|
2088
|
-
bool: True on success
|
|
2274
|
+
bool: `True` on success.
|
|
2275
|
+
|
|
2276
|
+
`False` if the `source` set does not exist or the element is not a member of the source set.
|
|
2089
2277
|
|
|
2090
2278
|
Examples:
|
|
2091
2279
|
>>> await client.smove("set1", "set2", "member1")
|
|
@@ -2102,7 +2290,7 @@ class CoreCommands(Protocol):
|
|
|
2102
2290
|
"""
|
|
2103
2291
|
Gets the union of all the given sets.
|
|
2104
2292
|
|
|
2105
|
-
See https://valkey.io/commands/sunion for more details.
|
|
2293
|
+
See [valkey.io](https://valkey.io/commands/sunion) for more details.
|
|
2106
2294
|
|
|
2107
2295
|
Note:
|
|
2108
2296
|
When in cluster mode, all `keys` must map to the same hash slot.
|
|
@@ -2112,7 +2300,8 @@ class CoreCommands(Protocol):
|
|
|
2112
2300
|
|
|
2113
2301
|
Returns:
|
|
2114
2302
|
Set[bytes]: A set of members which are present in at least one of the given sets.
|
|
2115
|
-
|
|
2303
|
+
|
|
2304
|
+
If none of the sets exist, an empty set will be returned.
|
|
2116
2305
|
|
|
2117
2306
|
Examples:
|
|
2118
2307
|
>>> await client.sadd("my_set1", ["member1", "member2"])
|
|
@@ -2132,7 +2321,7 @@ class CoreCommands(Protocol):
|
|
|
2132
2321
|
"""
|
|
2133
2322
|
Stores the members of the union of all given sets specified by `keys` into a new set at `destination`.
|
|
2134
2323
|
|
|
2135
|
-
See https://valkey.io/commands/sunionstore for more details.
|
|
2324
|
+
See [valkey.io](https://valkey.io/commands/sunionstore) for more details.
|
|
2136
2325
|
|
|
2137
2326
|
Note:
|
|
2138
2327
|
When in cluster mode, all keys in `keys` and `destination` must map to the same hash slot.
|
|
@@ -2160,7 +2349,7 @@ class CoreCommands(Protocol):
|
|
|
2160
2349
|
Stores the difference between the first set and all the successive sets in `keys` into a new set at
|
|
2161
2350
|
`destination`.
|
|
2162
2351
|
|
|
2163
|
-
See https://valkey.io/commands/sdiffstore for more details.
|
|
2352
|
+
See [valkey.io](https://valkey.io/commands/sdiffstore) for more details.
|
|
2164
2353
|
|
|
2165
2354
|
Note:
|
|
2166
2355
|
When in Cluster mode, all keys in `keys` and `destination` must map to the same hash slot.
|
|
@@ -2187,7 +2376,7 @@ class CoreCommands(Protocol):
|
|
|
2187
2376
|
"""
|
|
2188
2377
|
Gets the intersection of all the given sets.
|
|
2189
2378
|
|
|
2190
|
-
See https://valkey.io/commands/sinter for more details.
|
|
2379
|
+
See [valkey.io](https://valkey.io/commands/sinter) for more details.
|
|
2191
2380
|
|
|
2192
2381
|
Note:
|
|
2193
2382
|
When in cluster mode, all `keys` must map to the same hash slot.
|
|
@@ -2197,7 +2386,8 @@ class CoreCommands(Protocol):
|
|
|
2197
2386
|
|
|
2198
2387
|
Returns:
|
|
2199
2388
|
Set[bytes]: A set of members which are present in all given sets.
|
|
2200
|
-
|
|
2389
|
+
|
|
2390
|
+
If one or more sets do no exist, an empty set will be returned.
|
|
2201
2391
|
|
|
2202
2392
|
Examples:
|
|
2203
2393
|
>>> await client.sadd("my_set1", ["member1", "member2"])
|
|
@@ -2213,7 +2403,7 @@ class CoreCommands(Protocol):
|
|
|
2213
2403
|
"""
|
|
2214
2404
|
Stores the members of the intersection of all given sets specified by `keys` into a new set at `destination`.
|
|
2215
2405
|
|
|
2216
|
-
See https://valkey.io/commands/sinterstore for more details.
|
|
2406
|
+
See [valkey.io](https://valkey.io/commands/sinterstore) for more details.
|
|
2217
2407
|
|
|
2218
2408
|
Note:
|
|
2219
2409
|
When in Cluster mode, all `keys` and `destination` must map to the same hash slot.
|
|
@@ -2241,11 +2431,12 @@ class CoreCommands(Protocol):
|
|
|
2241
2431
|
) -> int:
|
|
2242
2432
|
"""
|
|
2243
2433
|
Gets the cardinality of the intersection of all the given sets.
|
|
2244
|
-
Optionally, a `limit` can be specified to stop the computation early if the intersection cardinality reaches the
|
|
2434
|
+
Optionally, a `limit` can be specified to stop the computation early if the intersection cardinality reaches the
|
|
2435
|
+
specified limit.
|
|
2245
2436
|
|
|
2246
2437
|
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
2247
2438
|
|
|
2248
|
-
See https://valkey.io/commands/sintercard for more details.
|
|
2439
|
+
See [valkey.io](https://valkey.io/commands/sintercard) for more details.
|
|
2249
2440
|
|
|
2250
2441
|
Args:
|
|
2251
2442
|
keys (List[TEncodable]): A list of keys representing the sets to intersect.
|
|
@@ -2277,7 +2468,7 @@ class CoreCommands(Protocol):
|
|
|
2277
2468
|
"""
|
|
2278
2469
|
Computes the difference between the first set and all the successive sets in `keys`.
|
|
2279
2470
|
|
|
2280
|
-
See https://valkey.io/commands/sdiff for more details.
|
|
2471
|
+
See [valkey.io](https://valkey.io/commands/sdiff) for more details.
|
|
2281
2472
|
|
|
2282
2473
|
Note:
|
|
2283
2474
|
When in cluster mode, all `keys` must map to the same hash slot.
|
|
@@ -2287,7 +2478,8 @@ class CoreCommands(Protocol):
|
|
|
2287
2478
|
|
|
2288
2479
|
Returns:
|
|
2289
2480
|
Set[bytes]: A set of elements representing the difference between the sets.
|
|
2290
|
-
|
|
2481
|
+
|
|
2482
|
+
If any of the keys in `keys` do not exist, they are treated as empty sets.
|
|
2291
2483
|
|
|
2292
2484
|
Examples:
|
|
2293
2485
|
>>> await client.sadd("set1", ["member1", "member2"])
|
|
@@ -2306,7 +2498,7 @@ class CoreCommands(Protocol):
|
|
|
2306
2498
|
"""
|
|
2307
2499
|
Checks whether each member is contained in the members of the set stored at `key`.
|
|
2308
2500
|
|
|
2309
|
-
See https://valkey.io/commands/smismember for more details.
|
|
2501
|
+
See [valkey.io](https://valkey.io/commands/smismember) for more details.
|
|
2310
2502
|
|
|
2311
2503
|
Args:
|
|
2312
2504
|
key (TEncodable): The key of the set to check.
|
|
@@ -2332,7 +2524,8 @@ class CoreCommands(Protocol):
|
|
|
2332
2524
|
element and so on.
|
|
2333
2525
|
These offsets can also be negative numbers indicating offsets starting at the end of the list, with -1 being the last
|
|
2334
2526
|
element of the list, -2 being the penultimate, and so on.
|
|
2335
|
-
|
|
2527
|
+
|
|
2528
|
+
See [valkey.io](https://valkey.io/commands/ltrim/) for more details.
|
|
2336
2529
|
|
|
2337
2530
|
Args:
|
|
2338
2531
|
key (TEncodable): The key of the list.
|
|
@@ -2341,10 +2534,13 @@ class CoreCommands(Protocol):
|
|
|
2341
2534
|
|
|
2342
2535
|
Returns:
|
|
2343
2536
|
TOK: A simple "OK" response.
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2537
|
+
|
|
2538
|
+
If `start` exceeds the end of the list, or if `start` is greater than `end`, the result will be an empty list
|
|
2539
|
+
(which causes `key` to be removed).
|
|
2540
|
+
|
|
2541
|
+
If `end` exceeds the actual end of the list, it will be treated like the last element of the list.
|
|
2542
|
+
|
|
2543
|
+
If `key` does not exist, "OK" will be returned without changes to the database.
|
|
2348
2544
|
|
|
2349
2545
|
Examples:
|
|
2350
2546
|
>>> await client.ltrim("my_list", 0, 1)
|
|
@@ -2362,7 +2558,8 @@ class CoreCommands(Protocol):
|
|
|
2362
2558
|
If `count` is negative, it removes elements equal to `element` moving from tail to head.
|
|
2363
2559
|
If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
|
|
2364
2560
|
equal to `element`.
|
|
2365
|
-
|
|
2561
|
+
|
|
2562
|
+
See [valkey.io](https://valkey.io/commands/lrem/) for more details.
|
|
2366
2563
|
|
|
2367
2564
|
Args:
|
|
2368
2565
|
key (TEncodable): The key of the list.
|
|
@@ -2371,7 +2568,8 @@ class CoreCommands(Protocol):
|
|
|
2371
2568
|
|
|
2372
2569
|
Returns:
|
|
2373
2570
|
int: The number of removed elements.
|
|
2374
|
-
|
|
2571
|
+
|
|
2572
|
+
If `key` does not exist, 0 is returned.
|
|
2375
2573
|
|
|
2376
2574
|
Examples:
|
|
2377
2575
|
>>> await client.lrem("my_list", 2, "value")
|
|
@@ -2385,14 +2583,16 @@ class CoreCommands(Protocol):
|
|
|
2385
2583
|
async def llen(self, key: TEncodable) -> int:
|
|
2386
2584
|
"""
|
|
2387
2585
|
Get the length of the list stored at `key`.
|
|
2388
|
-
|
|
2586
|
+
|
|
2587
|
+
See [valkey.io](https://valkey.io/commands/llen/) for details.
|
|
2389
2588
|
|
|
2390
2589
|
Args:
|
|
2391
2590
|
key (TEncodable): The key of the list.
|
|
2392
2591
|
|
|
2393
2592
|
Returns:
|
|
2394
2593
|
int: The length of the list at the specified key.
|
|
2395
|
-
|
|
2594
|
+
|
|
2595
|
+
If `key` does not exist, it is interpreted as an empty list and 0 is returned.
|
|
2396
2596
|
|
|
2397
2597
|
Examples:
|
|
2398
2598
|
>>> await client.llen("my_list")
|
|
@@ -2403,7 +2603,8 @@ class CoreCommands(Protocol):
|
|
|
2403
2603
|
async def exists(self, keys: List[TEncodable]) -> int:
|
|
2404
2604
|
"""
|
|
2405
2605
|
Returns the number of keys in `keys` that exist in the database.
|
|
2406
|
-
|
|
2606
|
+
|
|
2607
|
+
See [valkey.io](https://valkey.io/commands/exists/) for more details.
|
|
2407
2608
|
|
|
2408
2609
|
Note:
|
|
2409
2610
|
In cluster mode, if keys in `keys` map to different hash slots,
|
|
@@ -2419,7 +2620,7 @@ class CoreCommands(Protocol):
|
|
|
2419
2620
|
|
|
2420
2621
|
Returns:
|
|
2421
2622
|
int: The number of keys that exist. If the same existing key is mentioned in `keys` multiple times,
|
|
2422
|
-
|
|
2623
|
+
it will be counted multiple times.
|
|
2423
2624
|
|
|
2424
2625
|
Examples:
|
|
2425
2626
|
>>> await client.exists(["key1", "key2", "key3"])
|
|
@@ -2433,7 +2634,8 @@ class CoreCommands(Protocol):
|
|
|
2433
2634
|
A key is ignored if it does not exist.
|
|
2434
2635
|
This command, similar to DEL, removes specified keys and ignores non-existent ones.
|
|
2435
2636
|
However, this command does not block the server, while [DEL](https://valkey.io/commands/del) does.
|
|
2436
|
-
|
|
2637
|
+
|
|
2638
|
+
See [valkey.io](https://valkey.io/commands/unlink/) for more details.
|
|
2437
2639
|
|
|
2438
2640
|
Note:
|
|
2439
2641
|
In cluster mode, if keys in `key_value_map` map to different hash slots,
|
|
@@ -2467,7 +2669,8 @@ class CoreCommands(Protocol):
|
|
|
2467
2669
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2468
2670
|
If `seconds` is a non-positive number, the key will be deleted rather than expired.
|
|
2469
2671
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2470
|
-
|
|
2672
|
+
|
|
2673
|
+
See [valkey.io](https://valkey.io/commands/expire/) for more details.
|
|
2471
2674
|
|
|
2472
2675
|
Args:
|
|
2473
2676
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2475,8 +2678,10 @@ class CoreCommands(Protocol):
|
|
|
2475
2678
|
option (ExpireOptions, optional): The expire option.
|
|
2476
2679
|
|
|
2477
2680
|
Returns:
|
|
2478
|
-
bool:
|
|
2479
|
-
|
|
2681
|
+
bool: `True` if the timeout was set.
|
|
2682
|
+
|
|
2683
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2684
|
+
operation is skipped due to the provided arguments).
|
|
2480
2685
|
|
|
2481
2686
|
Examples:
|
|
2482
2687
|
>>> await client.expire("my_key", 60)
|
|
@@ -2500,7 +2705,8 @@ class CoreCommands(Protocol):
|
|
|
2500
2705
|
deleted.
|
|
2501
2706
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2502
2707
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2503
|
-
|
|
2708
|
+
|
|
2709
|
+
See [valkey.io](https://valkey.io/commands/expireat/) for more details.
|
|
2504
2710
|
|
|
2505
2711
|
Args:
|
|
2506
2712
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2508,8 +2714,10 @@ class CoreCommands(Protocol):
|
|
|
2508
2714
|
option (Optional[ExpireOptions]): The expire option.
|
|
2509
2715
|
|
|
2510
2716
|
Returns:
|
|
2511
|
-
bool:
|
|
2512
|
-
|
|
2717
|
+
bool: `True` if the timeout was set.
|
|
2718
|
+
|
|
2719
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2720
|
+
operation is skipped due to the provided arguments).
|
|
2513
2721
|
|
|
2514
2722
|
Examples:
|
|
2515
2723
|
>>> await client.expireAt("my_key", 1672531200, ExpireOptions.HasNoExpiry)
|
|
@@ -2533,7 +2741,8 @@ class CoreCommands(Protocol):
|
|
|
2533
2741
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2534
2742
|
If `milliseconds` is a non-positive number, the key will be deleted rather than expired.
|
|
2535
2743
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2536
|
-
|
|
2744
|
+
|
|
2745
|
+
See [valkey.io](https://valkey.io/commands/pexpire/) for more details.
|
|
2537
2746
|
|
|
2538
2747
|
Args:
|
|
2539
2748
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2541,8 +2750,10 @@ class CoreCommands(Protocol):
|
|
|
2541
2750
|
option (Optional[ExpireOptions]): The expire option.
|
|
2542
2751
|
|
|
2543
2752
|
Returns:
|
|
2544
|
-
bool:
|
|
2545
|
-
|
|
2753
|
+
bool: `True` if the timeout was set
|
|
2754
|
+
|
|
2755
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2756
|
+
operation is skipped due to the provided arguments).
|
|
2546
2757
|
|
|
2547
2758
|
Examples:
|
|
2548
2759
|
>>> await client.pexpire("my_key", 60000, ExpireOptions.HasNoExpiry)
|
|
@@ -2568,7 +2779,8 @@ class CoreCommands(Protocol):
|
|
|
2568
2779
|
deleted.
|
|
2569
2780
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2570
2781
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2571
|
-
|
|
2782
|
+
|
|
2783
|
+
See [valkey.io](https://valkey.io/commands/pexpireat/) for more details.
|
|
2572
2784
|
|
|
2573
2785
|
Args:
|
|
2574
2786
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2576,8 +2788,10 @@ class CoreCommands(Protocol):
|
|
|
2576
2788
|
option (Optional[ExpireOptions]): The expire option.
|
|
2577
2789
|
|
|
2578
2790
|
Returns:
|
|
2579
|
-
bool:
|
|
2580
|
-
|
|
2791
|
+
bool: `True` if the timeout was set.
|
|
2792
|
+
|
|
2793
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2794
|
+
operation is skipped due to the provided arguments).
|
|
2581
2795
|
|
|
2582
2796
|
Examples:
|
|
2583
2797
|
>>> await client.pexpireAt("my_key", 1672531200000, ExpireOptions.HasNoExpiry)
|
|
@@ -2596,13 +2810,17 @@ class CoreCommands(Protocol):
|
|
|
2596
2810
|
the given `key` will expire, in seconds.
|
|
2597
2811
|
To get the expiration with millisecond precision, use `pexpiretime`.
|
|
2598
2812
|
|
|
2599
|
-
See https://valkey.io/commands/expiretime/ for details.
|
|
2813
|
+
See [valkey.io](https://valkey.io/commands/expiretime/) for details.
|
|
2600
2814
|
|
|
2601
2815
|
Args:
|
|
2602
2816
|
key (TEncodable): The `key` to determine the expiration value of.
|
|
2603
2817
|
|
|
2604
2818
|
Returns:
|
|
2605
|
-
int: The expiration Unix timestamp in seconds
|
|
2819
|
+
int: The expiration Unix timestamp in seconds.
|
|
2820
|
+
|
|
2821
|
+
-2 if `key` does not exist.
|
|
2822
|
+
|
|
2823
|
+
-1 if `key` exists but has no associated expire.
|
|
2606
2824
|
|
|
2607
2825
|
Examples:
|
|
2608
2826
|
>>> await client.expiretime("my_key")
|
|
@@ -2623,13 +2841,17 @@ class CoreCommands(Protocol):
|
|
|
2623
2841
|
Returns the absolute Unix timestamp (since January 1, 1970) at which
|
|
2624
2842
|
the given `key` will expire, in milliseconds.
|
|
2625
2843
|
|
|
2626
|
-
See https://valkey.io/commands/pexpiretime/ for details.
|
|
2844
|
+
See [valkey.io](https://valkey.io/commands/pexpiretime/) for details.
|
|
2627
2845
|
|
|
2628
2846
|
Args:
|
|
2629
2847
|
key (TEncodable): The `key` to determine the expiration value of.
|
|
2630
2848
|
|
|
2631
2849
|
Returns:
|
|
2632
|
-
int: The expiration Unix timestamp in milliseconds
|
|
2850
|
+
int: The expiration Unix timestamp in milliseconds.
|
|
2851
|
+
|
|
2852
|
+
-2 if `key` does not exist.
|
|
2853
|
+
|
|
2854
|
+
-1 if `key` exists but has no associated expiration.
|
|
2633
2855
|
|
|
2634
2856
|
Examples:
|
|
2635
2857
|
>>> await client.pexpiretime("my_key")
|
|
@@ -2648,13 +2870,18 @@ class CoreCommands(Protocol):
|
|
|
2648
2870
|
async def ttl(self, key: TEncodable) -> int:
|
|
2649
2871
|
"""
|
|
2650
2872
|
Returns the remaining time to live of `key` that has a timeout.
|
|
2651
|
-
|
|
2873
|
+
|
|
2874
|
+
See [valkey.io](https://valkey.io/commands/ttl/) for more details.
|
|
2652
2875
|
|
|
2653
2876
|
Args:
|
|
2654
2877
|
key (TEncodable): The key to return its timeout.
|
|
2655
2878
|
|
|
2656
2879
|
Returns:
|
|
2657
|
-
int: TTL in seconds
|
|
2880
|
+
int: TTL in seconds.
|
|
2881
|
+
|
|
2882
|
+
-2 if `key` does not exist.
|
|
2883
|
+
|
|
2884
|
+
-1 if `key` exists but has no associated expire.
|
|
2658
2885
|
|
|
2659
2886
|
Examples:
|
|
2660
2887
|
>>> await client.ttl("my_key")
|
|
@@ -2672,13 +2899,18 @@ class CoreCommands(Protocol):
|
|
|
2672
2899
|
) -> int:
|
|
2673
2900
|
"""
|
|
2674
2901
|
Returns the remaining time to live of `key` that has a timeout, in milliseconds.
|
|
2675
|
-
|
|
2902
|
+
|
|
2903
|
+
See [valkey.io](https://valkey.io/commands/pttl) for more details.
|
|
2676
2904
|
|
|
2677
2905
|
Args:
|
|
2678
2906
|
key (TEncodable): The key to return its timeout.
|
|
2679
2907
|
|
|
2680
2908
|
Returns:
|
|
2681
|
-
int: TTL in milliseconds.
|
|
2909
|
+
int: TTL in milliseconds.
|
|
2910
|
+
|
|
2911
|
+
-2 if `key` does not exist.
|
|
2912
|
+
|
|
2913
|
+
-1 if `key` exists but has no associated expire.
|
|
2682
2914
|
|
|
2683
2915
|
Examples:
|
|
2684
2916
|
>>> await client.pttl("my_key")
|
|
@@ -2699,13 +2931,15 @@ class CoreCommands(Protocol):
|
|
|
2699
2931
|
Remove the existing timeout on `key`, turning the key from volatile (a key with an expire set) to
|
|
2700
2932
|
persistent (a key that will never expire as no timeout is associated).
|
|
2701
2933
|
|
|
2702
|
-
See https://valkey.io/commands/persist/ for more details.
|
|
2934
|
+
See [valkey.io](https://valkey.io/commands/persist/) for more details.
|
|
2703
2935
|
|
|
2704
2936
|
Args:
|
|
2705
2937
|
key (TEncodable): The key to remove the existing timeout on.
|
|
2706
2938
|
|
|
2707
2939
|
Returns:
|
|
2708
|
-
bool: False if `key` does not exist or does not have an associated timeout
|
|
2940
|
+
bool: `False` if `key` does not exist or does not have an associated timeout.
|
|
2941
|
+
|
|
2942
|
+
`True` if the timeout has been removed.
|
|
2709
2943
|
|
|
2710
2944
|
Examples:
|
|
2711
2945
|
>>> await client.persist("my_key")
|
|
@@ -2720,13 +2954,14 @@ class CoreCommands(Protocol):
|
|
|
2720
2954
|
"""
|
|
2721
2955
|
Returns the bytes string representation of the type of the value stored at `key`.
|
|
2722
2956
|
|
|
2723
|
-
See https://valkey.io/commands/type/ for more details.
|
|
2957
|
+
See [valkey.io](https://valkey.io/commands/type/) for more details.
|
|
2724
2958
|
|
|
2725
2959
|
Args:
|
|
2726
2960
|
key (TEncodable): The key to check its data type.
|
|
2727
2961
|
|
|
2728
2962
|
Returns:
|
|
2729
2963
|
bytes: If the key exists, the type of the stored value is returned.
|
|
2964
|
+
|
|
2730
2965
|
Otherwise, a b"none" bytes string is returned.
|
|
2731
2966
|
|
|
2732
2967
|
Examples:
|
|
@@ -2748,20 +2983,28 @@ class CoreCommands(Protocol):
|
|
|
2748
2983
|
"""
|
|
2749
2984
|
Adds an entry to the specified stream stored at `key`. If the `key` doesn't exist, the stream is created.
|
|
2750
2985
|
|
|
2751
|
-
See https://valkey.io/commands/xadd for more details.
|
|
2986
|
+
See [valkey.io](https://valkey.io/commands/xadd) for more details.
|
|
2752
2987
|
|
|
2753
2988
|
Args:
|
|
2754
2989
|
key (TEncodable): The key of the stream.
|
|
2755
2990
|
values (List[Tuple[TEncodable, TEncodable]]): Field-value pairs to be added to the entry.
|
|
2756
|
-
options (Optional[StreamAddOptions]): Additional options for adding entries to the stream. Default to None.
|
|
2991
|
+
options (Optional[StreamAddOptions]): Additional options for adding entries to the stream. Default to None.
|
|
2992
|
+
See `StreamAddOptions`.
|
|
2757
2993
|
|
|
2758
2994
|
Returns:
|
|
2759
|
-
bytes: The id of the added entry
|
|
2995
|
+
bytes: The id of the added entry.
|
|
2996
|
+
|
|
2997
|
+
`None` if `options.make_stream` is set to False and no stream with the matching
|
|
2998
|
+
`key` exists.
|
|
2760
2999
|
|
|
2761
3000
|
Example:
|
|
2762
3001
|
>>> await client.xadd("mystream", [("field", "value"), ("field2", "value2")])
|
|
2763
3002
|
b"1615957011958-0" # Example stream entry ID.
|
|
2764
|
-
>>> await client.xadd(
|
|
3003
|
+
>>> await client.xadd(
|
|
3004
|
+
... "non_existing_stream",
|
|
3005
|
+
... [(field, "foo1"), (field2, "bar1")],
|
|
3006
|
+
... StreamAddOptions(id="0-1", make_stream=False)
|
|
3007
|
+
... )
|
|
2765
3008
|
None # The key doesn't exist, therefore, None is returned.
|
|
2766
3009
|
>>> await client.xadd("non_existing_stream", [(field, "foo1"), (field2, "bar1")], StreamAddOptions(id="0-1"))
|
|
2767
3010
|
b"0-1" # Returns the stream id.
|
|
@@ -2781,7 +3024,7 @@ class CoreCommands(Protocol):
|
|
|
2781
3024
|
"""
|
|
2782
3025
|
Removes the specified entries by id from a stream, and returns the number of entries deleted.
|
|
2783
3026
|
|
|
2784
|
-
See https://valkey.io/commands/xdel for more details.
|
|
3027
|
+
See [valkey.io](https://valkey.io/commands/xdel) for more details.
|
|
2785
3028
|
|
|
2786
3029
|
Args:
|
|
2787
3030
|
key (TEncodable): The key of the stream.
|
|
@@ -2789,7 +3032,7 @@ class CoreCommands(Protocol):
|
|
|
2789
3032
|
|
|
2790
3033
|
Returns:
|
|
2791
3034
|
int: The number of entries removed from the stream. This number may be less than the number of entries in
|
|
2792
|
-
|
|
3035
|
+
`ids`, if the specified `ids` don't exist in the stream.
|
|
2793
3036
|
|
|
2794
3037
|
Examples:
|
|
2795
3038
|
>>> await client.xdel("key", ["1538561698944-0", "1538561698944-1"])
|
|
@@ -2810,14 +3053,16 @@ class CoreCommands(Protocol):
|
|
|
2810
3053
|
"""
|
|
2811
3054
|
Trims the stream stored at `key` by evicting older entries.
|
|
2812
3055
|
|
|
2813
|
-
See https://valkey.io/commands/xtrim for more details.
|
|
3056
|
+
See [valkey.io](https://valkey.io/commands/xtrim) for more details.
|
|
2814
3057
|
|
|
2815
3058
|
Args:
|
|
2816
3059
|
key (TEncodable): The key of the stream.
|
|
2817
3060
|
options (StreamTrimOptions): Options detailing how to trim the stream. See `StreamTrimOptions`.
|
|
2818
3061
|
|
|
2819
3062
|
Returns:
|
|
2820
|
-
int: TThe number of entries deleted from the stream.
|
|
3063
|
+
int: TThe number of entries deleted from the stream.
|
|
3064
|
+
|
|
3065
|
+
If `key` doesn't exist, 0 is returned.
|
|
2821
3066
|
|
|
2822
3067
|
Example:
|
|
2823
3068
|
>>> await client.xadd("mystream", [("field", "value"), ("field2", "value2")], StreamAddOptions(id="0-1"))
|
|
@@ -2834,13 +3079,15 @@ class CoreCommands(Protocol):
|
|
|
2834
3079
|
"""
|
|
2835
3080
|
Returns the number of entries in the stream stored at `key`.
|
|
2836
3081
|
|
|
2837
|
-
See https://valkey.io/commands/xlen for more details.
|
|
3082
|
+
See [valkey.io](https://valkey.io/commands/xlen) for more details.
|
|
2838
3083
|
|
|
2839
3084
|
Args:
|
|
2840
3085
|
key (TEncodable): The key of the stream.
|
|
2841
3086
|
|
|
2842
3087
|
Returns:
|
|
2843
|
-
int: The number of entries in the stream.
|
|
3088
|
+
int: The number of entries in the stream.
|
|
3089
|
+
|
|
3090
|
+
If `key` does not exist, returns 0.
|
|
2844
3091
|
|
|
2845
3092
|
Examples:
|
|
2846
3093
|
>>> await client.xadd("mystream", [("field", "value")])
|
|
@@ -2863,25 +3110,30 @@ class CoreCommands(Protocol):
|
|
|
2863
3110
|
"""
|
|
2864
3111
|
Returns stream entries matching a given range of IDs.
|
|
2865
3112
|
|
|
2866
|
-
See https://valkey.io/commands/xrange for more details.
|
|
3113
|
+
See [valkey.io](https://valkey.io/commands/xrange) for more details.
|
|
2867
3114
|
|
|
2868
3115
|
Args:
|
|
2869
3116
|
key (TEncodable): The key of the stream.
|
|
2870
3117
|
start (StreamRangeBound): The starting stream ID bound for the range.
|
|
3118
|
+
|
|
2871
3119
|
- Use `IdBound` to specify a stream ID.
|
|
2872
3120
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
2873
3121
|
- Use `MinId` to start with the minimum available ID.
|
|
3122
|
+
|
|
2874
3123
|
end (StreamRangeBound): The ending stream ID bound for the range.
|
|
3124
|
+
|
|
2875
3125
|
- Use `IdBound` to specify a stream ID.
|
|
2876
3126
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
2877
3127
|
- Use `MaxId` to end with the maximum available ID.
|
|
3128
|
+
|
|
2878
3129
|
count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
|
|
2879
3130
|
If `count` is not provided, all stream entries in the range will be returned.
|
|
2880
3131
|
|
|
2881
3132
|
Returns:
|
|
2882
3133
|
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
|
|
2883
|
-
|
|
2884
|
-
|
|
3134
|
+
list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3135
|
+
|
|
3136
|
+
Returns None if the range arguments are not applicable.
|
|
2885
3137
|
|
|
2886
3138
|
Examples:
|
|
2887
3139
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="0-1"))
|
|
@@ -2912,25 +3164,30 @@ class CoreCommands(Protocol):
|
|
|
2912
3164
|
Returns stream entries matching a given range of IDs in reverse order. Equivalent to `XRANGE` but returns the
|
|
2913
3165
|
entries in reverse order.
|
|
2914
3166
|
|
|
2915
|
-
See https://valkey.io/commands/xrevrange for more details.
|
|
3167
|
+
See [valkey.io](https://valkey.io/commands/xrevrange) for more details.
|
|
2916
3168
|
|
|
2917
3169
|
Args:
|
|
2918
3170
|
key (TEncodable): The key of the stream.
|
|
2919
3171
|
end (StreamRangeBound): The ending stream ID bound for the range.
|
|
3172
|
+
|
|
2920
3173
|
- Use `IdBound` to specify a stream ID.
|
|
2921
3174
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
2922
3175
|
- Use `MaxId` to end with the maximum available ID.
|
|
3176
|
+
|
|
2923
3177
|
start (StreamRangeBound): The starting stream ID bound for the range.
|
|
3178
|
+
|
|
2924
3179
|
- Use `IdBound` to specify a stream ID.
|
|
2925
3180
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
2926
3181
|
- Use `MinId` to start with the minimum available ID.
|
|
3182
|
+
|
|
2927
3183
|
count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
|
|
2928
3184
|
If `count` is not provided, all stream entries in the range will be returned.
|
|
2929
3185
|
|
|
2930
3186
|
Returns:
|
|
2931
3187
|
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
|
|
2932
|
-
|
|
2933
|
-
|
|
3188
|
+
list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3189
|
+
|
|
3190
|
+
Returns None if the range arguments are not applicable.
|
|
2934
3191
|
|
|
2935
3192
|
Examples:
|
|
2936
3193
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="0-1"))
|
|
@@ -2958,7 +3215,7 @@ class CoreCommands(Protocol):
|
|
|
2958
3215
|
"""
|
|
2959
3216
|
Reads entries from the given streams.
|
|
2960
3217
|
|
|
2961
|
-
See https://valkey.io/commands/xread for more details.
|
|
3218
|
+
See [valkey.io](https://valkey.io/commands/xread) for more details.
|
|
2962
3219
|
|
|
2963
3220
|
Note:
|
|
2964
3221
|
When in cluster mode, all keys in `keys_and_ids` must map to the same hash slot.
|
|
@@ -2969,9 +3226,12 @@ class CoreCommands(Protocol):
|
|
|
2969
3226
|
|
|
2970
3227
|
Returns:
|
|
2971
3228
|
Optional[Mapping[bytes, Mapping[bytes, List[List[bytes]]]]]: A mapping of stream keys, to a mapping of stream IDs,
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3229
|
+
to a list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3230
|
+
|
|
3231
|
+
None will be returned under the following conditions:
|
|
3232
|
+
|
|
3233
|
+
- All key-ID pairs in `keys_and_ids` have either a non-existing key or a non-existing ID, or there are no
|
|
3234
|
+
entries after the given ID.
|
|
2975
3235
|
- The `BLOCK` option is specified and the timeout is hit.
|
|
2976
3236
|
|
|
2977
3237
|
Examples:
|
|
@@ -3007,7 +3267,7 @@ class CoreCommands(Protocol):
|
|
|
3007
3267
|
"""
|
|
3008
3268
|
Creates a new consumer group uniquely identified by `group_name` for the stream stored at `key`.
|
|
3009
3269
|
|
|
3010
|
-
See https://valkey.io/commands/xgroup-create for more details.
|
|
3270
|
+
See [valkey.io](https://valkey.io/commands/xgroup-create) for more details.
|
|
3011
3271
|
|
|
3012
3272
|
Args:
|
|
3013
3273
|
key (TEncodable): The key of the stream.
|
|
@@ -3038,14 +3298,16 @@ class CoreCommands(Protocol):
|
|
|
3038
3298
|
"""
|
|
3039
3299
|
Destroys the consumer group `group_name` for the stream stored at `key`.
|
|
3040
3300
|
|
|
3041
|
-
See https://valkey.io/commands/xgroup-destroy for more details.
|
|
3301
|
+
See [valkey.io](https://valkey.io/commands/xgroup-destroy) for more details.
|
|
3042
3302
|
|
|
3043
3303
|
Args:
|
|
3044
3304
|
key (TEncodable): The key of the stream.
|
|
3045
3305
|
group_name (TEncodable): The consumer group name to delete.
|
|
3046
3306
|
|
|
3047
3307
|
Returns:
|
|
3048
|
-
bool: True if the consumer group was destroyed.
|
|
3308
|
+
bool: True if the consumer group was destroyed.
|
|
3309
|
+
|
|
3310
|
+
Otherwise, returns False.
|
|
3049
3311
|
|
|
3050
3312
|
Examples:
|
|
3051
3313
|
>>> await client.xgroup_destroy("mystream", "mygroup")
|
|
@@ -3065,7 +3327,7 @@ class CoreCommands(Protocol):
|
|
|
3065
3327
|
"""
|
|
3066
3328
|
Creates a consumer named `consumer_name` in the consumer group `group_name` for the stream stored at `key`.
|
|
3067
3329
|
|
|
3068
|
-
See https://valkey.io/commands/xgroup-createconsumer for more details.
|
|
3330
|
+
See [valkey.io](https://valkey.io/commands/xgroup-createconsumer) for more details.
|
|
3069
3331
|
|
|
3070
3332
|
Args:
|
|
3071
3333
|
key (TEncodable): The key of the stream.
|
|
@@ -3073,7 +3335,9 @@ class CoreCommands(Protocol):
|
|
|
3073
3335
|
consumer_name (TEncodable): The newly created consumer.
|
|
3074
3336
|
|
|
3075
3337
|
Returns:
|
|
3076
|
-
bool: True if the consumer is created.
|
|
3338
|
+
bool: True if the consumer is created.
|
|
3339
|
+
|
|
3340
|
+
Otherwise, returns False.
|
|
3077
3341
|
|
|
3078
3342
|
Examples:
|
|
3079
3343
|
>>> await client.xgroup_create_consumer("mystream", "mygroup", "myconsumer")
|
|
@@ -3095,7 +3359,7 @@ class CoreCommands(Protocol):
|
|
|
3095
3359
|
"""
|
|
3096
3360
|
Deletes a consumer named `consumer_name` in the consumer group `group_name` for the stream stored at `key`.
|
|
3097
3361
|
|
|
3098
|
-
See https://valkey.io/commands/xgroup-delconsumer for more details.
|
|
3362
|
+
See [valkey.io](https://valkey.io/commands/xgroup-delconsumer) for more details.
|
|
3099
3363
|
|
|
3100
3364
|
Args:
|
|
3101
3365
|
key (TEncodable): The key of the stream.
|
|
@@ -3126,7 +3390,7 @@ class CoreCommands(Protocol):
|
|
|
3126
3390
|
"""
|
|
3127
3391
|
Set the last delivered ID for a consumer group.
|
|
3128
3392
|
|
|
3129
|
-
See https://valkey.io/commands/xgroup-setid for more details.
|
|
3393
|
+
See [valkey.io](https://valkey.io/commands/xgroup-setid) for more details.
|
|
3130
3394
|
|
|
3131
3395
|
Args:
|
|
3132
3396
|
key (TEncodable): The key of the stream.
|
|
@@ -3161,7 +3425,7 @@ class CoreCommands(Protocol):
|
|
|
3161
3425
|
"""
|
|
3162
3426
|
Reads entries from the given streams owned by a consumer group.
|
|
3163
3427
|
|
|
3164
|
-
See https://valkey.io/commands/xreadgroup for more details.
|
|
3428
|
+
See [valkey.io](https://valkey.io/commands/xreadgroup) for more details.
|
|
3165
3429
|
|
|
3166
3430
|
Note:
|
|
3167
3431
|
When in cluster mode, all keys in `keys_and_ids` must map to the same hash slot.
|
|
@@ -3175,8 +3439,9 @@ class CoreCommands(Protocol):
|
|
|
3175
3439
|
|
|
3176
3440
|
Returns:
|
|
3177
3441
|
Optional[Mapping[bytes, Mapping[bytes, Optional[List[List[bytes]]]]]]: A mapping of stream keys, to a mapping of
|
|
3178
|
-
|
|
3179
|
-
|
|
3442
|
+
stream IDs, to a list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3443
|
+
|
|
3444
|
+
Returns None if the BLOCK option is given and a timeout occurs, or if there is no stream that can be served.
|
|
3180
3445
|
|
|
3181
3446
|
Examples:
|
|
3182
3447
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="1-0"))
|
|
@@ -3212,7 +3477,7 @@ class CoreCommands(Protocol):
|
|
|
3212
3477
|
This command should be called on pending messages so that such messages do not get processed again by the
|
|
3213
3478
|
consumer group.
|
|
3214
3479
|
|
|
3215
|
-
See https://valkey.io/commands/xack for more details.
|
|
3480
|
+
See [valkey.io](https://valkey.io/commands/xack) for more details.
|
|
3216
3481
|
|
|
3217
3482
|
Args:
|
|
3218
3483
|
key (TEncodable): The key of the stream.
|
|
@@ -3249,7 +3514,7 @@ class CoreCommands(Protocol):
|
|
|
3249
3514
|
"""
|
|
3250
3515
|
Returns stream message summary information for pending messages for the given consumer group.
|
|
3251
3516
|
|
|
3252
|
-
See https://valkey.io/commands/xpending for more details.
|
|
3517
|
+
See [valkey.io](https://valkey.io/commands/xpending) for more details.
|
|
3253
3518
|
|
|
3254
3519
|
Args:
|
|
3255
3520
|
key (TEncodable): The key of the stream.
|
|
@@ -3257,14 +3522,15 @@ class CoreCommands(Protocol):
|
|
|
3257
3522
|
|
|
3258
3523
|
Returns:
|
|
3259
3524
|
List[Union[int, bytes, List[List[bytes]], None]]: A list that includes the summary of pending messages, with the
|
|
3260
|
-
|
|
3525
|
+
format `[num_group_messages, start_id, end_id, [[consumer_name, num_consumer_messages]]]`, where:
|
|
3526
|
+
|
|
3261
3527
|
- `num_group_messages`: The total number of pending messages for this consumer group.
|
|
3262
3528
|
- `start_id`: The smallest ID among the pending messages.
|
|
3263
3529
|
- `end_id`: The greatest ID among the pending messages.
|
|
3264
3530
|
- `[[consumer_name, num_consumer_messages]]`: A 2D list of every consumer in the consumer group with at
|
|
3265
|
-
|
|
3531
|
+
least one pending message, and the number of pending messages it has.
|
|
3266
3532
|
|
|
3267
|
-
|
|
3533
|
+
If there are no pending messages for the given consumer group, `[0, None, None, None]` will be returned.
|
|
3268
3534
|
|
|
3269
3535
|
Examples:
|
|
3270
3536
|
>>> await client.xpending("my_stream", "my_group")
|
|
@@ -3287,34 +3553,46 @@ class CoreCommands(Protocol):
|
|
|
3287
3553
|
"""
|
|
3288
3554
|
Returns an extended form of stream message information for pending messages matching a given range of IDs.
|
|
3289
3555
|
|
|
3290
|
-
See https://valkey.io/commands/xpending for more details.
|
|
3556
|
+
See [valkey.io](https://valkey.io/commands/xpending) for more details.
|
|
3291
3557
|
|
|
3292
3558
|
Args:
|
|
3293
3559
|
key (TEncodable): The key of the stream.
|
|
3294
3560
|
group_name (TEncodable): The consumer group name.
|
|
3295
3561
|
start (StreamRangeBound): The starting stream ID bound for the range.
|
|
3562
|
+
|
|
3296
3563
|
- Use `IdBound` to specify a stream ID.
|
|
3297
3564
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
3298
3565
|
- Use `MinId` to start with the minimum available ID.
|
|
3566
|
+
|
|
3299
3567
|
end (StreamRangeBound): The ending stream ID bound for the range.
|
|
3568
|
+
|
|
3300
3569
|
- Use `IdBound` to specify a stream ID.
|
|
3301
3570
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
3302
3571
|
- Use `MaxId` to end with the maximum available ID.
|
|
3572
|
+
|
|
3303
3573
|
count (int): Limits the number of messages returned.
|
|
3304
3574
|
options (Optional[StreamPendingOptions]): The stream pending options.
|
|
3305
3575
|
|
|
3306
3576
|
Returns:
|
|
3307
3577
|
List[List[Union[bytes, int]]]: A list of lists, where each inner list is a length 4 list containing extended
|
|
3308
|
-
|
|
3578
|
+
message information with the format `[[id, consumer_name, time_elapsed, num_delivered]]`, where:
|
|
3579
|
+
|
|
3309
3580
|
- `id`: The ID of the message.
|
|
3310
3581
|
- `consumer_name`: The name of the consumer that fetched the message and has still to acknowledge it. We
|
|
3311
|
-
|
|
3582
|
+
call it the current owner of the message.
|
|
3312
3583
|
- `time_elapsed`: The number of milliseconds that elapsed since the last time this message was delivered
|
|
3313
|
-
|
|
3584
|
+
to this consumer.
|
|
3314
3585
|
- `num_delivered`: The number of times this message was delivered.
|
|
3315
3586
|
|
|
3316
3587
|
Examples:
|
|
3317
|
-
>>> await client.xpending_range(
|
|
3588
|
+
>>> await client.xpending_range(
|
|
3589
|
+
... "my_stream",
|
|
3590
|
+
... "my_group",
|
|
3591
|
+
... MinId(),
|
|
3592
|
+
... MaxId(),
|
|
3593
|
+
... 10,
|
|
3594
|
+
... StreamPendingOptions(consumer_name="my_consumer")
|
|
3595
|
+
... )
|
|
3318
3596
|
[[b"1-0", b"my_consumer", 1234, 1], [b"1-1", b"my_consumer", 1123, 1]]
|
|
3319
3597
|
# Extended stream entry information for the pending entries associated with "my_consumer".
|
|
3320
3598
|
"""
|
|
@@ -3336,7 +3614,7 @@ class CoreCommands(Protocol):
|
|
|
3336
3614
|
"""
|
|
3337
3615
|
Changes the ownership of a pending message.
|
|
3338
3616
|
|
|
3339
|
-
See https://valkey.io/commands/xclaim for more details.
|
|
3617
|
+
See [valkey.io](https://valkey.io/commands/xclaim) for more details.
|
|
3340
3618
|
|
|
3341
3619
|
Args:
|
|
3342
3620
|
key (TEncodable): The key of the stream.
|
|
@@ -3347,11 +3625,15 @@ class CoreCommands(Protocol):
|
|
|
3347
3625
|
options (Optional[StreamClaimOptions]): Stream claim options.
|
|
3348
3626
|
|
|
3349
3627
|
Returns:
|
|
3350
|
-
Mapping[bytes, List[List[bytes]]]: A Mapping of message entries with the format
|
|
3351
|
-
|
|
3628
|
+
Mapping[bytes, List[List[bytes]]]: A Mapping of message entries with the format::
|
|
3629
|
+
|
|
3630
|
+
{"entryId": [["entry", "data"], ...], ...}
|
|
3631
|
+
|
|
3632
|
+
that are claimed by the consumer.
|
|
3352
3633
|
|
|
3353
3634
|
Examples:
|
|
3354
|
-
|
|
3635
|
+
read messages from streamId for consumer1:
|
|
3636
|
+
|
|
3355
3637
|
>>> await client.xreadgroup({"mystream": ">"}, "mygroup", "consumer1")
|
|
3356
3638
|
{
|
|
3357
3639
|
b"mystream": {
|
|
@@ -3386,7 +3668,7 @@ class CoreCommands(Protocol):
|
|
|
3386
3668
|
Changes the ownership of a pending message. This function returns a List with
|
|
3387
3669
|
only the message/entry IDs, and is equivalent to using JUSTID in the Valkey API.
|
|
3388
3670
|
|
|
3389
|
-
See https://valkey.io/commands/xclaim for more details.
|
|
3671
|
+
See [valkey.io](https://valkey.io/commands/xclaim) for more details.
|
|
3390
3672
|
|
|
3391
3673
|
Args:
|
|
3392
3674
|
key (TEncodable): The key of the stream.
|
|
@@ -3400,7 +3682,8 @@ class CoreCommands(Protocol):
|
|
|
3400
3682
|
List[bytes]: A List of message ids claimed by the consumer.
|
|
3401
3683
|
|
|
3402
3684
|
Examples:
|
|
3403
|
-
|
|
3685
|
+
read messages from streamId for consumer1:
|
|
3686
|
+
|
|
3404
3687
|
>>> await client.xreadgroup({"mystream": ">"}, "mygroup", "consumer1")
|
|
3405
3688
|
{
|
|
3406
3689
|
b"mystream": {
|
|
@@ -3441,7 +3724,7 @@ class CoreCommands(Protocol):
|
|
|
3441
3724
|
"""
|
|
3442
3725
|
Transfers ownership of pending stream entries that match the specified criteria.
|
|
3443
3726
|
|
|
3444
|
-
See https://valkey.io/commands/xautoclaim for more details.
|
|
3727
|
+
See [valkey.io](https://valkey.io/commands/xautoclaim) for more details.
|
|
3445
3728
|
|
|
3446
3729
|
Args:
|
|
3447
3730
|
key (TEncodable): The key of the stream.
|
|
@@ -3454,17 +3737,19 @@ class CoreCommands(Protocol):
|
|
|
3454
3737
|
|
|
3455
3738
|
Returns:
|
|
3456
3739
|
List[Union[bytes, Mapping[bytes, List[List[bytes]]], List[bytes]]]: A list containing the following elements:
|
|
3740
|
+
|
|
3457
3741
|
- A stream ID to be used as the start argument for the next call to `XAUTOCLAIM`. This ID is equivalent
|
|
3458
|
-
|
|
3459
|
-
|
|
3742
|
+
to the next ID in the stream after the entries that were scanned, or "0-0" if the entire stream was
|
|
3743
|
+
scanned.
|
|
3460
3744
|
- A mapping of the claimed entries, with the keys being the claimed entry IDs and the values being a
|
|
3461
|
-
|
|
3745
|
+
2D list of the field-value pairs in the format `[[field1, value1], [field2, value2], ...]`.
|
|
3462
3746
|
- If you are using Valkey 7.0.0 or above, the response list will also include a list containing the
|
|
3463
|
-
|
|
3464
|
-
|
|
3747
|
+
message IDs that were in the Pending Entries List but no longer exist in the stream. These IDs are
|
|
3748
|
+
deleted from the Pending Entries List.
|
|
3465
3749
|
|
|
3466
3750
|
Examples:
|
|
3467
|
-
|
|
3751
|
+
Valkey version < 7.0.0:
|
|
3752
|
+
|
|
3468
3753
|
>>> await client.xautoclaim("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3469
3754
|
[
|
|
3470
3755
|
b"0-0",
|
|
@@ -3478,7 +3763,8 @@ class CoreCommands(Protocol):
|
|
|
3478
3763
|
# Stream entry "1-1" was idle for over an hour and was thus claimed by "my_consumer". The entire stream
|
|
3479
3764
|
# was scanned.
|
|
3480
3765
|
|
|
3481
|
-
|
|
3766
|
+
Valkey version 7.0.0 and above:
|
|
3767
|
+
|
|
3482
3768
|
>>> await client.xautoclaim("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3483
3769
|
[
|
|
3484
3770
|
b"0-0",
|
|
@@ -3525,7 +3811,7 @@ class CoreCommands(Protocol):
|
|
|
3525
3811
|
argument to further specify that the return value should contain a list of claimed IDs without their
|
|
3526
3812
|
field-value info.
|
|
3527
3813
|
|
|
3528
|
-
See https://valkey.io/commands/xautoclaim for more details.
|
|
3814
|
+
See [valkey.io](https://valkey.io/commands/xautoclaim) for more details.
|
|
3529
3815
|
|
|
3530
3816
|
Args:
|
|
3531
3817
|
key (TEncodable): The key of the stream.
|
|
@@ -3538,22 +3824,25 @@ class CoreCommands(Protocol):
|
|
|
3538
3824
|
|
|
3539
3825
|
Returns:
|
|
3540
3826
|
List[Union[bytes, List[bytes]]]: A list containing the following elements:
|
|
3827
|
+
|
|
3541
3828
|
- A stream ID to be used as the start argument for the next call to `XAUTOCLAIM`. This ID is equivalent
|
|
3542
|
-
|
|
3543
|
-
|
|
3829
|
+
to the next ID in the stream after the entries that were scanned, or "0-0" if the entire stream was
|
|
3830
|
+
scanned.
|
|
3544
3831
|
- A list of the IDs for the claimed entries.
|
|
3545
3832
|
- If you are using Valkey 7.0.0 or above, the response list will also include a list containing the
|
|
3546
|
-
|
|
3547
|
-
|
|
3833
|
+
message IDs that were in the Pending Entries List but no longer exist in the stream. These IDs are
|
|
3834
|
+
deleted from the Pending Entries List.
|
|
3548
3835
|
|
|
3549
3836
|
Examples:
|
|
3550
|
-
|
|
3837
|
+
Valkey version < 7.0.0:
|
|
3838
|
+
|
|
3551
3839
|
>>> await client.xautoclaim_just_id("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3552
3840
|
[b"0-0", [b"1-1"]]
|
|
3553
3841
|
# Stream entry "1-1" was idle for over an hour and was thus claimed by "my_consumer". The entire stream
|
|
3554
3842
|
# was scanned.
|
|
3555
3843
|
|
|
3556
|
-
|
|
3844
|
+
Valkey version 7.0.0 and above:
|
|
3845
|
+
|
|
3557
3846
|
>>> await client.xautoclaim_just_id("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3558
3847
|
[b"0-0", [b"1-1"], [b"1-2"]]
|
|
3559
3848
|
# Stream entry "1-1" was idle for over an hour and was thus claimed by "my_consumer". The entire stream
|
|
@@ -3586,14 +3875,14 @@ class CoreCommands(Protocol):
|
|
|
3586
3875
|
"""
|
|
3587
3876
|
Returns the list of all consumer groups and their attributes for the stream stored at `key`.
|
|
3588
3877
|
|
|
3589
|
-
See https://valkey.io/commands/xinfo-groups for more details.
|
|
3878
|
+
See [valkey.io](https://valkey.io/commands/xinfo-groups) for more details.
|
|
3590
3879
|
|
|
3591
3880
|
Args:
|
|
3592
3881
|
key (TEncodable): The key of the stream.
|
|
3593
3882
|
|
|
3594
3883
|
Returns:
|
|
3595
3884
|
List[Mapping[bytes, Union[bytes, int, None]]]: A list of mappings, where each mapping represents the
|
|
3596
|
-
|
|
3885
|
+
attributes of a consumer group for the stream at `key`.
|
|
3597
3886
|
|
|
3598
3887
|
Examples:
|
|
3599
3888
|
>>> await client.xinfo_groups("my_stream")
|
|
@@ -3631,7 +3920,7 @@ class CoreCommands(Protocol):
|
|
|
3631
3920
|
Returns the list of all consumers and their attributes for the given consumer group of the stream stored at
|
|
3632
3921
|
`key`.
|
|
3633
3922
|
|
|
3634
|
-
See https://valkey.io/commands/xinfo-consumers for more details.
|
|
3923
|
+
See [valkey.io](https://valkey.io/commands/xinfo-consumers) for more details.
|
|
3635
3924
|
|
|
3636
3925
|
Args:
|
|
3637
3926
|
key (TEncodable): The key of the stream.
|
|
@@ -3639,7 +3928,7 @@ class CoreCommands(Protocol):
|
|
|
3639
3928
|
|
|
3640
3929
|
Returns:
|
|
3641
3930
|
List[Mapping[bytes, Union[bytes, int]]]: A list of mappings, where each mapping contains the attributes of a
|
|
3642
|
-
|
|
3931
|
+
consumer for the given consumer group of the stream at `key`.
|
|
3643
3932
|
|
|
3644
3933
|
Examples:
|
|
3645
3934
|
>>> await client.xinfo_consumers("my_stream", "my_group")
|
|
@@ -3671,14 +3960,14 @@ class CoreCommands(Protocol):
|
|
|
3671
3960
|
"""
|
|
3672
3961
|
Returns information about the stream stored at `key`. To get more detailed information, use `xinfo_stream_full`.
|
|
3673
3962
|
|
|
3674
|
-
See https://valkey.io/commands/xinfo-stream for more details.
|
|
3963
|
+
See [valkey.io](https://valkey.io/commands/xinfo-stream) for more details.
|
|
3675
3964
|
|
|
3676
3965
|
Args:
|
|
3677
3966
|
key (TEncodable): The key of the stream.
|
|
3678
3967
|
|
|
3679
3968
|
Returns:
|
|
3680
3969
|
TXInfoStreamResponse: A mapping of stream information for the given `key`. See the example for a sample
|
|
3681
|
-
|
|
3970
|
+
response.
|
|
3682
3971
|
|
|
3683
3972
|
Examples:
|
|
3684
3973
|
>>> await client.xinfo_stream("my_stream")
|
|
@@ -3716,7 +4005,7 @@ class CoreCommands(Protocol):
|
|
|
3716
4005
|
"""
|
|
3717
4006
|
Returns verbose information about the stream stored at `key`.
|
|
3718
4007
|
|
|
3719
|
-
See https://valkey.io/commands/xinfo-stream for more details.
|
|
4008
|
+
See [valkey.io](https://valkey.io/commands/xinfo-stream) for more details.
|
|
3720
4009
|
|
|
3721
4010
|
Args:
|
|
3722
4011
|
key (TEncodable): The key of the stream.
|
|
@@ -3725,7 +4014,7 @@ class CoreCommands(Protocol):
|
|
|
3725
4014
|
|
|
3726
4015
|
Returns:
|
|
3727
4016
|
TXInfoStreamFullResponse: A mapping of detailed stream information for the given `key`. See the example for
|
|
3728
|
-
|
|
4017
|
+
a sample response.
|
|
3729
4018
|
|
|
3730
4019
|
Examples:
|
|
3731
4020
|
>>> await client.xinfo_stream_full("my_stream")
|
|
@@ -3815,25 +4104,43 @@ class CoreCommands(Protocol):
|
|
|
3815
4104
|
Adds geospatial members with their positions to the specified sorted set stored at `key`.
|
|
3816
4105
|
If a member is already a part of the sorted set, its position is updated.
|
|
3817
4106
|
|
|
3818
|
-
See https://valkey.io/commands/geoadd for more details.
|
|
4107
|
+
See [valkey.io](https://valkey.io/commands/geoadd) for more details.
|
|
3819
4108
|
|
|
3820
4109
|
Args:
|
|
3821
4110
|
key (TEncodable): The key of the sorted set.
|
|
3822
|
-
members_geospatialdata (Mapping[TEncodable, GeospatialData]): A mapping of member names to their corresponding
|
|
3823
|
-
|
|
4111
|
+
members_geospatialdata (Mapping[TEncodable, GeospatialData]): A mapping of member names to their corresponding
|
|
4112
|
+
positions. See `GeospatialData`. The command will report an error when the user attempts to index coordinates
|
|
4113
|
+
outside the specified ranges.
|
|
3824
4114
|
existing_options (Optional[ConditionalChange]): Options for handling existing members.
|
|
4115
|
+
|
|
3825
4116
|
- NX: Only add new elements.
|
|
3826
4117
|
- XX: Only update existing elements.
|
|
3827
|
-
|
|
4118
|
+
|
|
4119
|
+
changed (bool): Modify the return value to return the number of changed elements, instead of the number of new
|
|
4120
|
+
elements added.
|
|
3828
4121
|
|
|
3829
4122
|
Returns:
|
|
3830
4123
|
int: The number of elements added to the sorted set.
|
|
4124
|
+
|
|
3831
4125
|
If `changed` is set, returns the number of elements updated in the sorted set.
|
|
3832
4126
|
|
|
3833
4127
|
Examples:
|
|
3834
|
-
>>> await client.geoadd(
|
|
4128
|
+
>>> await client.geoadd(
|
|
4129
|
+
... "my_sorted_set",
|
|
4130
|
+
... {
|
|
4131
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4132
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4133
|
+
... }
|
|
4134
|
+
... )
|
|
3835
4135
|
2 # Indicates that two elements have been added to the sorted set "my_sorted_set".
|
|
3836
|
-
>>> await client.geoadd(
|
|
4136
|
+
>>> await client.geoadd(
|
|
4137
|
+
... "my_sorted_set",
|
|
4138
|
+
... {
|
|
4139
|
+
... "Palermo": GeospatialData(14.361389, 38.115556)
|
|
4140
|
+
... },
|
|
4141
|
+
... existing_options=ConditionalChange.XX,
|
|
4142
|
+
... changed=True
|
|
4143
|
+
... )
|
|
3837
4144
|
1 # Updates the position of an existing member in the sorted set "my_sorted_set".
|
|
3838
4145
|
"""
|
|
3839
4146
|
args = [key]
|
|
@@ -3865,7 +4172,7 @@ class CoreCommands(Protocol):
|
|
|
3865
4172
|
"""
|
|
3866
4173
|
Returns the distance between two members in the geospatial index stored at `key`.
|
|
3867
4174
|
|
|
3868
|
-
See https://valkey.io/commands/geodist for more details.
|
|
4175
|
+
See [valkey.io](https://valkey.io/commands/geodist) for more details.
|
|
3869
4176
|
|
|
3870
4177
|
Args:
|
|
3871
4178
|
key (TEncodable): The key of the sorted set.
|
|
@@ -3876,10 +4183,17 @@ class CoreCommands(Protocol):
|
|
|
3876
4183
|
|
|
3877
4184
|
Returns:
|
|
3878
4185
|
Optional[float]: The distance between `member1` and `member2`.
|
|
4186
|
+
|
|
3879
4187
|
If one or both members do not exist, or if the key does not exist, returns None.
|
|
3880
4188
|
|
|
3881
4189
|
Examples:
|
|
3882
|
-
>>> await client.geoadd(
|
|
4190
|
+
>>> await client.geoadd(
|
|
4191
|
+
... "my_geo_set",
|
|
4192
|
+
... {
|
|
4193
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4194
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4195
|
+
... }
|
|
4196
|
+
... )
|
|
3883
4197
|
>>> await client.geodist("my_geo_set", "Palermo", "Catania")
|
|
3884
4198
|
166274.1516 # Indicates the distance between "Palermo" and "Catania" in meters.
|
|
3885
4199
|
>>> await client.geodist("my_geo_set", "Palermo", "Palermo", unit=GeoUnit.KILOMETERS)
|
|
@@ -3903,18 +4217,26 @@ class CoreCommands(Protocol):
|
|
|
3903
4217
|
Returns the GeoHash bytes strings representing the positions of all the specified members in the sorted set stored at
|
|
3904
4218
|
`key`.
|
|
3905
4219
|
|
|
3906
|
-
See https://valkey.io/commands/geohash for more details.
|
|
4220
|
+
See [valkey.io](https://valkey.io/commands/geohash) for more details.
|
|
3907
4221
|
|
|
3908
4222
|
Args:
|
|
3909
4223
|
key (TEncodable): The key of the sorted set.
|
|
3910
4224
|
members (List[TEncodable]): The list of members whose GeoHash bytes strings are to be retrieved.
|
|
3911
4225
|
|
|
3912
4226
|
Returns:
|
|
3913
|
-
List[Optional[bytes]]: A list of GeoHash bytes strings representing the positions of the specified members stored
|
|
4227
|
+
List[Optional[bytes]]: A list of GeoHash bytes strings representing the positions of the specified members stored
|
|
4228
|
+
at `key`.
|
|
4229
|
+
|
|
3914
4230
|
If a member does not exist in the sorted set, a None value is returned for that member.
|
|
3915
4231
|
|
|
3916
4232
|
Examples:
|
|
3917
|
-
>>> await client.geoadd(
|
|
4233
|
+
>>> await client.geoadd(
|
|
4234
|
+
... "my_geo_sorted_set",
|
|
4235
|
+
... {
|
|
4236
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4237
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4238
|
+
... }
|
|
4239
|
+
... )
|
|
3918
4240
|
>>> await client.geohash("my_geo_sorted_set", ["Palermo", "Catania", "some city])
|
|
3919
4241
|
["sqc8b49rny0", "sqdtr74hyu0", None] # Indicates the GeoHash bytes strings for the specified members.
|
|
3920
4242
|
"""
|
|
@@ -3929,10 +4251,10 @@ class CoreCommands(Protocol):
|
|
|
3929
4251
|
members: List[TEncodable],
|
|
3930
4252
|
) -> List[Optional[List[float]]]:
|
|
3931
4253
|
"""
|
|
3932
|
-
Returns the positions (longitude and latitude) of all the given members of a geospatial index in the sorted set stored
|
|
3933
|
-
`key`.
|
|
4254
|
+
Returns the positions (longitude and latitude) of all the given members of a geospatial index in the sorted set stored
|
|
4255
|
+
at `key`.
|
|
3934
4256
|
|
|
3935
|
-
See https://valkey.io/commands/geopos for more details.
|
|
4257
|
+
See [valkey.io](https://valkey.io/commands/geopos) for more details.
|
|
3936
4258
|
|
|
3937
4259
|
Args:
|
|
3938
4260
|
key (TEncodable): The key of the sorted set.
|
|
@@ -3940,10 +4262,17 @@ class CoreCommands(Protocol):
|
|
|
3940
4262
|
|
|
3941
4263
|
Returns:
|
|
3942
4264
|
List[Optional[List[float]]]: A list of positions (longitude and latitude) corresponding to the given members.
|
|
4265
|
+
|
|
3943
4266
|
If a member does not exist, its position will be None.
|
|
3944
4267
|
|
|
3945
4268
|
Example:
|
|
3946
|
-
>>> await client.geoadd(
|
|
4269
|
+
>>> await client.geoadd(
|
|
4270
|
+
... "my_geo_sorted_set",
|
|
4271
|
+
... {
|
|
4272
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4273
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4274
|
+
... }
|
|
4275
|
+
... )
|
|
3947
4276
|
>>> await client.geopos("my_geo_sorted_set", ["Palermo", "Catania", "NonExisting"])
|
|
3948
4277
|
[[13.36138933897018433, 38.11555639549629859], [15.08726745843887329, 37.50266842333162032], None]
|
|
3949
4278
|
"""
|
|
@@ -3964,9 +4293,10 @@ class CoreCommands(Protocol):
|
|
|
3964
4293
|
with_hash: bool = False,
|
|
3965
4294
|
) -> List[Union[bytes, List[Union[bytes, float, int, List[float]]]]]:
|
|
3966
4295
|
"""
|
|
3967
|
-
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4296
|
+
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4297
|
+
area.
|
|
3968
4298
|
|
|
3969
|
-
See https://valkey.io/commands/geosearch/ for more details.
|
|
4299
|
+
See [valkey.io](https://valkey.io/commands/geosearch/) for more details.
|
|
3970
4300
|
|
|
3971
4301
|
Args:
|
|
3972
4302
|
key (TEncodable): The key of the sorted set representing geospatial data.
|
|
@@ -3976,8 +4306,10 @@ class CoreCommands(Protocol):
|
|
|
3976
4306
|
For circular area search, see `GeoSearchByRadius`.
|
|
3977
4307
|
For rectangular area search, see `GeoSearchByBox`.
|
|
3978
4308
|
order_by (Optional[OrderBy]): Specifies the order in which the results should be returned.
|
|
3979
|
-
|
|
3980
|
-
|
|
4309
|
+
|
|
4310
|
+
- `ASC`: Sorts items from the nearest to the farthest, relative to the center point.
|
|
4311
|
+
- `DESC`: Sorts items from the farthest to the nearest, relative to the center point.
|
|
4312
|
+
|
|
3981
4313
|
If not specified, the results would be unsorted.
|
|
3982
4314
|
count (Optional[GeoSearchCount]): Specifies the maximum number of results to return. See `GeoSearchCount`.
|
|
3983
4315
|
If not specified, return all results.
|
|
@@ -3987,19 +4319,45 @@ class CoreCommands(Protocol):
|
|
|
3987
4319
|
with_hash (bool): Whether to include geohash of the returned items. Defaults to False.
|
|
3988
4320
|
|
|
3989
4321
|
Returns:
|
|
3990
|
-
List[Union[bytes, List[Union[bytes, float, int, List[float]]]]]: By default, returns a list of members (locations)
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4322
|
+
List[Union[bytes, List[Union[bytes, float, int, List[float]]]]]: By default, returns a list of members (locations)
|
|
4323
|
+
names.
|
|
4324
|
+
|
|
4325
|
+
If any of `with_coord`, `with_dist` or `with_hash` are True, returns an array of arrays, we're each sub array
|
|
4326
|
+
represents a single item in the following order:
|
|
4327
|
+
|
|
4328
|
+
- (bytes): The member (location) name.
|
|
4329
|
+
- (float): The distance from the center as a floating point number, in the same unit specified in the radius,
|
|
4330
|
+
if `with_dist` is set to True.
|
|
4331
|
+
- (int): The Geohash integer, if `with_hash` is set to True.
|
|
4332
|
+
- List[float]: The coordinates as a two item [longitude,latitude] array, if `with_coord` is set to True.
|
|
4333
|
+
|
|
4334
|
+
Examples:
|
|
4335
|
+
>>> await client.geoadd(
|
|
4336
|
+
... "my_geo_sorted_set",
|
|
4337
|
+
... {
|
|
4338
|
+
... "edge1": GeospatialData(12.758489, 38.788135),
|
|
4339
|
+
... "edge2": GeospatialData(17.241510, 38.788135)
|
|
4340
|
+
... }
|
|
4341
|
+
... )
|
|
4342
|
+
>>> await client.geoadd(
|
|
4343
|
+
... "my_geo_sorted_set",
|
|
4344
|
+
... {
|
|
4345
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4346
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4347
|
+
... }
|
|
4348
|
+
... )
|
|
4000
4349
|
>>> await client.geosearch("my_geo_sorted_set", "Catania", GeoSearchByRadius(175, GeoUnit.MILES), OrderBy.DESC)
|
|
4001
|
-
['Palermo', 'Catania'] # Returned the locations names within the radius of 175 miles, with the center being
|
|
4002
|
-
|
|
4350
|
+
['Palermo', 'Catania'] # Returned the locations names within the radius of 175 miles, with the center being
|
|
4351
|
+
# 'Catania' from farthest to nearest.
|
|
4352
|
+
>>> await client.geosearch(
|
|
4353
|
+
... "my_geo_sorted_set",
|
|
4354
|
+
... GeospatialData(15, 37),
|
|
4355
|
+
... GeoSearchByBox(400, 400, GeoUnit.KILOMETERS),
|
|
4356
|
+
... OrderBy.DESC,
|
|
4357
|
+
... with_coord=true,
|
|
4358
|
+
... with_dist=true,
|
|
4359
|
+
... with_hash=true
|
|
4360
|
+
... )
|
|
4003
4361
|
[
|
|
4004
4362
|
[
|
|
4005
4363
|
b"Catania",
|
|
@@ -4017,7 +4375,8 @@ class CoreCommands(Protocol):
|
|
|
4017
4375
|
b"edge1",
|
|
4018
4376
|
[279.7405, 3479273021651468, [12.75848776102066, 38.78813451624225]],
|
|
4019
4377
|
],
|
|
4020
|
-
] # Returns locations within the square box of 400 km, with the center being a specific point, from nearest
|
|
4378
|
+
] # Returns locations within the square box of 400 km, with the center being a specific point, from nearest
|
|
4379
|
+
# to farthest with the dist, hash and coords.
|
|
4021
4380
|
|
|
4022
4381
|
Since: Valkey version 6.2.0.
|
|
4023
4382
|
"""
|
|
@@ -4047,7 +4406,8 @@ class CoreCommands(Protocol):
|
|
|
4047
4406
|
store_dist: bool = False,
|
|
4048
4407
|
) -> int:
|
|
4049
4408
|
"""
|
|
4050
|
-
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4409
|
+
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4410
|
+
area and stores the result in `destination`.
|
|
4051
4411
|
If `destination` already exists, it is overwritten. Otherwise, a new sorted set will be created.
|
|
4052
4412
|
|
|
4053
4413
|
To get the result directly, see `geosearch`.
|
|
@@ -4055,34 +4415,55 @@ class CoreCommands(Protocol):
|
|
|
4055
4415
|
Note:
|
|
4056
4416
|
When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
4057
4417
|
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4418
|
+
Args:
|
|
4419
|
+
destination (TEncodable): The key to store the search results.
|
|
4420
|
+
source (TEncodable): The key of the sorted set representing geospatial data to search from.
|
|
4421
|
+
search_from (Union[str, bytes, GeospatialData]): The location to search from. Can be specified either as a
|
|
4422
|
+
member from the sorted set or as a geospatial data (see `GeospatialData`).
|
|
4423
|
+
search_by (Union[GeoSearchByRadius, GeoSearchByBox]): The search criteria.
|
|
4424
|
+
For circular area search, see `GeoSearchByRadius`.
|
|
4425
|
+
For rectangular area search, see `GeoSearchByBox`.
|
|
4426
|
+
count (Optional[GeoSearchCount]): Specifies the maximum number of results to store. See `GeoSearchCount`.
|
|
4427
|
+
If not specified, stores all results.
|
|
4428
|
+
store_dist (bool): Determines what is stored as the sorted set score. Defaults to False.
|
|
4429
|
+
|
|
4430
|
+
- If set to False, the geohash of the location will be stored as the sorted set score.
|
|
4431
|
+
- If set to True, the distance from the center of the shape (circle or box) will be stored as the sorted
|
|
4432
|
+
set score.
|
|
4433
|
+
The distance is represented as a floating-point number in the same unit specified for that shape.
|
|
4072
4434
|
|
|
4073
4435
|
Returns:
|
|
4074
4436
|
int: The number of elements in the resulting sorted set stored at `destination`.
|
|
4075
4437
|
|
|
4076
4438
|
Examples:
|
|
4077
|
-
>>> await client.geoadd(
|
|
4078
|
-
|
|
4439
|
+
>>> await client.geoadd(
|
|
4440
|
+
... "my_geo_sorted_set",
|
|
4441
|
+
... {
|
|
4442
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4443
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4444
|
+
... }
|
|
4445
|
+
... )
|
|
4446
|
+
>>> await client.geosearchstore(
|
|
4447
|
+
... "my_dest_sorted_set",
|
|
4448
|
+
... "my_geo_sorted_set",
|
|
4449
|
+
... "Catania",
|
|
4450
|
+
... GeoSearchByRadius(175, GeoUnit.MILES)
|
|
4451
|
+
... )
|
|
4079
4452
|
2 # Number of elements stored in "my_dest_sorted_set".
|
|
4080
4453
|
>>> await client.zrange_withscores("my_dest_sorted_set", RangeByIndex(0, -1))
|
|
4081
|
-
{b"Palermo": 3479099956230698.0, b"Catania": 3479447370796909.0} # The elements within te search area, with
|
|
4082
|
-
|
|
4454
|
+
{b"Palermo": 3479099956230698.0, b"Catania": 3479447370796909.0} # The elements within te search area, with
|
|
4455
|
+
# their geohash as score.
|
|
4456
|
+
>>> await client.geosearchstore(
|
|
4457
|
+
... "my_dest_sorted_set",
|
|
4458
|
+
... "my_geo_sorted_set",
|
|
4459
|
+
... GeospatialData(15, 37),
|
|
4460
|
+
... GeoSearchByBox(400, 400, GeoUnit.KILOMETERS),
|
|
4461
|
+
... store_dist=True
|
|
4462
|
+
... )
|
|
4083
4463
|
2 # Number of elements stored in "my_dest_sorted_set", with distance as score.
|
|
4084
4464
|
>>> await client.zrange_withscores("my_dest_sorted_set", RangeByIndex(0, -1))
|
|
4085
|
-
{b"Catania": 56.4412578701582, b"Palermo": 190.44242984775784} # The elements within te search area, with the
|
|
4465
|
+
{b"Catania": 56.4412578701582, b"Palermo": 190.44242984775784} # The elements within te search area, with the
|
|
4466
|
+
# distance as score.
|
|
4086
4467
|
|
|
4087
4468
|
Since: Valkey version 6.2.0.
|
|
4088
4469
|
"""
|
|
@@ -4115,27 +4496,41 @@ class CoreCommands(Protocol):
|
|
|
4115
4496
|
Adds members with their scores to the sorted set stored at `key`.
|
|
4116
4497
|
If a member is already a part of the sorted set, its score is updated.
|
|
4117
4498
|
|
|
4118
|
-
See https://valkey.io/commands/zadd/ for more details.
|
|
4499
|
+
See [valkey.io](https://valkey.io/commands/zadd/) for more details.
|
|
4119
4500
|
|
|
4120
4501
|
Args:
|
|
4121
4502
|
key (TEncodable): The key of the sorted set.
|
|
4122
4503
|
members_scores (Mapping[TEncodable, float]): A mapping of members to their corresponding scores.
|
|
4123
4504
|
existing_options (Optional[ConditionalChange]): Options for handling existing members.
|
|
4505
|
+
|
|
4124
4506
|
- NX: Only add new elements.
|
|
4125
4507
|
- XX: Only update existing elements.
|
|
4508
|
+
|
|
4126
4509
|
update_condition (Optional[UpdateOptions]): Options for updating scores.
|
|
4510
|
+
|
|
4127
4511
|
- GT: Only update scores greater than the current values.
|
|
4128
4512
|
- LT: Only update scores less than the current values.
|
|
4129
|
-
|
|
4513
|
+
|
|
4514
|
+
changed (bool): Modify the return value to return the number of changed elements, instead of the number of new
|
|
4515
|
+
elements added.
|
|
4130
4516
|
|
|
4131
4517
|
Returns:
|
|
4132
4518
|
int: The number of elements added to the sorted set.
|
|
4519
|
+
|
|
4133
4520
|
If `changed` is set, returns the number of elements updated in the sorted set.
|
|
4134
4521
|
|
|
4135
4522
|
Examples:
|
|
4136
4523
|
>>> await client.zadd("my_sorted_set", {"member1": 10.5, "member2": 8.2})
|
|
4137
4524
|
2 # Indicates that two elements have been added to the sorted set "my_sorted_set."
|
|
4138
|
-
>>> await client.zadd(
|
|
4525
|
+
>>> await client.zadd(
|
|
4526
|
+
... "existing_sorted_set",
|
|
4527
|
+
... {
|
|
4528
|
+
... "member1": 15.0,
|
|
4529
|
+
... "member2": 5.5
|
|
4530
|
+
... },
|
|
4531
|
+
... existing_options=ConditionalChange.XX,
|
|
4532
|
+
... changed=True
|
|
4533
|
+
... )
|
|
4139
4534
|
2 # Updates the scores of two existing members in the sorted set "existing_sorted_set."
|
|
4140
4535
|
"""
|
|
4141
4536
|
args = [key]
|
|
@@ -4175,24 +4570,29 @@ class CoreCommands(Protocol):
|
|
|
4175
4570
|
) -> Optional[float]:
|
|
4176
4571
|
"""
|
|
4177
4572
|
Increments the score of member in the sorted set stored at `key` by `increment`.
|
|
4178
|
-
If `member` does not exist in the sorted set, it is added with `increment` as its score (as if its previous score
|
|
4573
|
+
If `member` does not exist in the sorted set, it is added with `increment` as its score (as if its previous score
|
|
4574
|
+
was 0.0).
|
|
4179
4575
|
If `key` does not exist, a new sorted set with the specified member as its sole member is created.
|
|
4180
4576
|
|
|
4181
|
-
See https://valkey.io/commands/zadd/ for more details.
|
|
4577
|
+
See [valkey.io](https://valkey.io/commands/zadd/) for more details.
|
|
4182
4578
|
|
|
4183
4579
|
Args:
|
|
4184
4580
|
key (TEncodable): The key of the sorted set.
|
|
4185
4581
|
member (TEncodable): A member in the sorted set to increment.
|
|
4186
4582
|
increment (float): The score to increment the member.
|
|
4187
4583
|
existing_options (Optional[ConditionalChange]): Options for handling the member's existence.
|
|
4584
|
+
|
|
4188
4585
|
- NX: Only increment a member that doesn't exist.
|
|
4189
4586
|
- XX: Only increment an existing member.
|
|
4587
|
+
|
|
4190
4588
|
update_condition (Optional[UpdateOptions]): Options for updating the score.
|
|
4589
|
+
|
|
4191
4590
|
- GT: Only increment the score of the member if the new score will be greater than the current score.
|
|
4192
4591
|
- LT: Only increment (decrement) the score of the member if the new score will be less than the current score.
|
|
4193
4592
|
|
|
4194
4593
|
Returns:
|
|
4195
4594
|
Optional[float]: The score of the member.
|
|
4595
|
+
|
|
4196
4596
|
If there was a conflict with choosing the XX/NX/LT/GT options, the operation aborts and None is returned.
|
|
4197
4597
|
|
|
4198
4598
|
Examples:
|
|
@@ -4227,13 +4627,14 @@ class CoreCommands(Protocol):
|
|
|
4227
4627
|
"""
|
|
4228
4628
|
Returns the cardinality (number of elements) of the sorted set stored at `key`.
|
|
4229
4629
|
|
|
4230
|
-
See https://valkey.io/commands/zcard/ for more details.
|
|
4630
|
+
See [valkey.io](https://valkey.io/commands/zcard/) for more details.
|
|
4231
4631
|
|
|
4232
4632
|
Args:
|
|
4233
4633
|
key (TEncodable): The key of the sorted set.
|
|
4234
4634
|
|
|
4235
4635
|
Returns:
|
|
4236
4636
|
int: The number of elements in the sorted set.
|
|
4637
|
+
|
|
4237
4638
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
4238
4639
|
|
|
4239
4640
|
Examples:
|
|
@@ -4253,7 +4654,7 @@ class CoreCommands(Protocol):
|
|
|
4253
4654
|
"""
|
|
4254
4655
|
Returns the number of members in the sorted set stored at `key` with scores between `min_score` and `max_score`.
|
|
4255
4656
|
|
|
4256
|
-
See https://valkey.io/commands/zcount/ for more details.
|
|
4657
|
+
See [valkey.io](https://valkey.io/commands/zcount/) for more details.
|
|
4257
4658
|
|
|
4258
4659
|
Args:
|
|
4259
4660
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4266,23 +4667,30 @@ class CoreCommands(Protocol):
|
|
|
4266
4667
|
|
|
4267
4668
|
Returns:
|
|
4268
4669
|
int: The number of members in the specified score range.
|
|
4670
|
+
|
|
4269
4671
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
4672
|
+
|
|
4270
4673
|
If `max_score` < `min_score`, 0 is returned.
|
|
4271
4674
|
|
|
4272
4675
|
Examples:
|
|
4273
4676
|
>>> await client.zcount("my_sorted_set", ScoreBoundary(5.0 , is_inclusive=true) , InfBound.POS_INF)
|
|
4274
|
-
2 # Indicates that there are 2 members with scores between 5.0 (not exclusive) and +inf in the sorted set
|
|
4275
|
-
|
|
4677
|
+
2 # Indicates that there are 2 members with scores between 5.0 (not exclusive) and +inf in the sorted set
|
|
4678
|
+
# "my_sorted_set".
|
|
4679
|
+
>>> await client.zcount(
|
|
4680
|
+
... "my_sorted_set",
|
|
4681
|
+
... ScoreBoundary(5.0 , is_inclusive=true),
|
|
4682
|
+
... ScoreBoundary(10.0 , is_inclusive=false)
|
|
4683
|
+
... )
|
|
4276
4684
|
1 # Indicates that there is one ScoreBoundary with 5.0 < score <= 10.0 in the sorted set "my_sorted_set".
|
|
4277
4685
|
"""
|
|
4278
4686
|
score_min = (
|
|
4279
4687
|
min_score.value["score_arg"]
|
|
4280
|
-
if
|
|
4688
|
+
if isinstance(min_score, InfBound)
|
|
4281
4689
|
else min_score.value
|
|
4282
4690
|
)
|
|
4283
4691
|
score_max = (
|
|
4284
4692
|
max_score.value["score_arg"]
|
|
4285
|
-
if
|
|
4693
|
+
if isinstance(max_score, InfBound)
|
|
4286
4694
|
else max_score.value
|
|
4287
4695
|
)
|
|
4288
4696
|
return cast(
|
|
@@ -4300,7 +4708,7 @@ class CoreCommands(Protocol):
|
|
|
4300
4708
|
If `member` does not exist in the sorted set, it is added with `increment` as its score.
|
|
4301
4709
|
If `key` does not exist, a new sorted set is created with the specified member as its sole member.
|
|
4302
4710
|
|
|
4303
|
-
See https://valkey.io/commands/zincrby/ for more details.
|
|
4711
|
+
See [valkey.io](https://valkey.io/commands/zincrby/) for more details.
|
|
4304
4712
|
|
|
4305
4713
|
Args:
|
|
4306
4714
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4334,22 +4742,26 @@ class CoreCommands(Protocol):
|
|
|
4334
4742
|
If `count` is provided, up to `count` members with the highest scores are removed and returned.
|
|
4335
4743
|
Otherwise, only one member with the highest score is removed and returned.
|
|
4336
4744
|
|
|
4337
|
-
See https://valkey.io/commands/zpopmax for more details.
|
|
4745
|
+
See [valkey.io](https://valkey.io/commands/zpopmax) for more details.
|
|
4338
4746
|
|
|
4339
4747
|
Args:
|
|
4340
4748
|
key (TEncodable): The key of the sorted set.
|
|
4341
4749
|
count (Optional[int]): Specifies the quantity of members to pop. If not specified, pops one member.
|
|
4342
|
-
|
|
4750
|
+
If `count` is higher than the sorted set's cardinality, returns all members and their scores, ordered from
|
|
4751
|
+
highest to lowest.
|
|
4343
4752
|
|
|
4344
4753
|
Returns:
|
|
4345
|
-
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the highest score
|
|
4346
|
-
|
|
4754
|
+
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the highest score
|
|
4755
|
+
to the one with the lowest.
|
|
4756
|
+
|
|
4757
|
+
If `key` doesn't exist, it will be treated as an empty sorted set and the command returns an empty map.
|
|
4347
4758
|
|
|
4348
4759
|
Examples:
|
|
4349
4760
|
>>> await client.zpopmax("my_sorted_set")
|
|
4350
4761
|
{b'member1': 10.0} # Indicates that 'member1' with a score of 10.0 has been removed from the sorted set.
|
|
4351
4762
|
>>> await client.zpopmax("my_sorted_set", 2)
|
|
4352
|
-
{b'member2': 8.0, b'member3': 7.5} # Indicates that 'member2' with a score of 8.0 and 'member3' with a score
|
|
4763
|
+
{b'member2': 8.0, b'member3': 7.5} # Indicates that 'member2' with a score of 8.0 and 'member3' with a score
|
|
4764
|
+
# of 7.5 have been removed from the sorted set.
|
|
4353
4765
|
"""
|
|
4354
4766
|
return cast(
|
|
4355
4767
|
Mapping[bytes, float],
|
|
@@ -4366,13 +4778,14 @@ class CoreCommands(Protocol):
|
|
|
4366
4778
|
the order that they are given. Blocks the connection when there are no members to remove from any of the given
|
|
4367
4779
|
sorted sets.
|
|
4368
4780
|
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4781
|
+
Note:
|
|
4782
|
+
1. When in cluster mode, all keys must map to the same hash slot.
|
|
4783
|
+
2. `BZPOPMAX` is the blocking variant of `ZPOPMAX`.
|
|
4784
|
+
3. `BZPOPMAX` is a client blocking command, see
|
|
4785
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
4786
|
+
for more details and best practices.
|
|
4374
4787
|
|
|
4375
|
-
See https://valkey.io/commands/bzpopmax for more details.
|
|
4788
|
+
See [valkey.io](https://valkey.io/commands/bzpopmax) for more details.
|
|
4376
4789
|
|
|
4377
4790
|
Args:
|
|
4378
4791
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -4380,8 +4793,10 @@ class CoreCommands(Protocol):
|
|
|
4380
4793
|
A value of 0 will block indefinitely.
|
|
4381
4794
|
|
|
4382
4795
|
Returns:
|
|
4383
|
-
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4384
|
-
|
|
4796
|
+
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4797
|
+
itself, and the member score.
|
|
4798
|
+
|
|
4799
|
+
If no member could be popped and the `timeout` expired, returns None.
|
|
4385
4800
|
|
|
4386
4801
|
Examples:
|
|
4387
4802
|
>>> await client.zadd("my_sorted_set1", {"member1": 10.0, "member2": 5.0})
|
|
@@ -4402,22 +4817,25 @@ class CoreCommands(Protocol):
|
|
|
4402
4817
|
If `count` is provided, up to `count` members with the lowest scores are removed and returned.
|
|
4403
4818
|
Otherwise, only one member with the lowest score is removed and returned.
|
|
4404
4819
|
|
|
4405
|
-
See https://valkey.io/commands/zpopmin for more details.
|
|
4820
|
+
See [valkey.io](https://valkey.io/commands/zpopmin) for more details.
|
|
4406
4821
|
|
|
4407
4822
|
Args:
|
|
4408
4823
|
key (TEncodable): The key of the sorted set.
|
|
4409
4824
|
count (Optional[int]): Specifies the quantity of members to pop. If not specified, pops one member.
|
|
4410
|
-
|
|
4825
|
+
If `count` is higher than the sorted set's cardinality, returns all members and their scores.
|
|
4411
4826
|
|
|
4412
4827
|
Returns:
|
|
4413
|
-
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the lowest score
|
|
4414
|
-
|
|
4828
|
+
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the lowest score
|
|
4829
|
+
to the one with the highest.
|
|
4830
|
+
|
|
4831
|
+
If `key` doesn't exist, it will be treated as an empty sorted set and the command returns an empty map.
|
|
4415
4832
|
|
|
4416
4833
|
Examples:
|
|
4417
4834
|
>>> await client.zpopmin("my_sorted_set")
|
|
4418
4835
|
{b'member1': 5.0} # Indicates that 'member1' with a score of 5.0 has been removed from the sorted set.
|
|
4419
4836
|
>>> await client.zpopmin("my_sorted_set", 2)
|
|
4420
|
-
{b'member3': 7.5 , b'member2': 8.0} # Indicates that 'member3' with a score of 7.5 and 'member2' with a score
|
|
4837
|
+
{b'member3': 7.5 , b'member2': 8.0} # Indicates that 'member3' with a score of 7.5 and 'member2' with a score
|
|
4838
|
+
# of 8.0 have been removed from the sorted set.
|
|
4421
4839
|
"""
|
|
4422
4840
|
args: List[TEncodable] = [key, str(count)] if count else [key]
|
|
4423
4841
|
return cast(
|
|
@@ -4433,13 +4851,14 @@ class CoreCommands(Protocol):
|
|
|
4433
4851
|
the order that they are given. Blocks the connection when there are no members to remove from any of the given
|
|
4434
4852
|
sorted sets.
|
|
4435
4853
|
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4854
|
+
Note:
|
|
4855
|
+
1. When in cluster mode, all keys must map to the same hash slot.
|
|
4856
|
+
2. `BZPOPMIN` is the blocking variant of `ZPOPMIN`.
|
|
4857
|
+
3. `BZPOPMIN` is a client blocking command, see
|
|
4858
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
4859
|
+
for more details and best practices.
|
|
4441
4860
|
|
|
4442
|
-
See https://valkey.io/commands/bzpopmin for more details.
|
|
4861
|
+
See [valkey.io](https://valkey.io/commands/bzpopmin) for more details.
|
|
4443
4862
|
|
|
4444
4863
|
Args:
|
|
4445
4864
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -4447,8 +4866,10 @@ class CoreCommands(Protocol):
|
|
|
4447
4866
|
A value of 0 will block indefinitely.
|
|
4448
4867
|
|
|
4449
4868
|
Returns:
|
|
4450
|
-
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4451
|
-
|
|
4869
|
+
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4870
|
+
itself, and the member score.
|
|
4871
|
+
|
|
4872
|
+
If no member could be popped and the `timeout` expired, returns None.
|
|
4452
4873
|
|
|
4453
4874
|
Examples:
|
|
4454
4875
|
>>> await client.zadd("my_sorted_set1", {"member1": 10.0, "member2": 5.0})
|
|
@@ -4473,27 +4894,32 @@ class CoreCommands(Protocol):
|
|
|
4473
4894
|
|
|
4474
4895
|
ZRANGE can perform different types of range queries: by index (rank), by the score, or by lexicographical order.
|
|
4475
4896
|
|
|
4476
|
-
See https://valkey.io/commands/zrange/ for more details.
|
|
4897
|
+
See [valkey.io](https://valkey.io/commands/zrange/) for more details.
|
|
4477
4898
|
|
|
4478
4899
|
To get the elements with their scores, see zrange_withscores.
|
|
4479
4900
|
|
|
4480
4901
|
Args:
|
|
4481
4902
|
key (TEncodable): The key of the sorted set.
|
|
4482
|
-
range_query (Union[RangeByIndex, RangeByLex, RangeByScore]): The range query object representing the type of range
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4903
|
+
range_query (Union[RangeByIndex, RangeByLex, RangeByScore]): The range query object representing the type of range
|
|
4904
|
+
query to perform.
|
|
4905
|
+
|
|
4906
|
+
- For range queries by index (rank), use RangeByIndex.
|
|
4907
|
+
- For range queries by lexicographical order, use RangeByLex.
|
|
4908
|
+
- For range queries by score, use RangeByScore.
|
|
4909
|
+
|
|
4486
4910
|
reverse (bool): If True, reverses the sorted set, with index 0 as the element with the highest score.
|
|
4487
4911
|
|
|
4488
4912
|
Returns:
|
|
4489
4913
|
List[bytes]: A list of elements within the specified range.
|
|
4914
|
+
|
|
4490
4915
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns an empty array.
|
|
4491
4916
|
|
|
4492
4917
|
Examples:
|
|
4493
4918
|
>>> await client.zrange("my_sorted_set", RangeByIndex(0, -1))
|
|
4494
4919
|
[b'member1', b'member2', b'member3'] # Returns all members in ascending order.
|
|
4495
4920
|
>>> await client.zrange("my_sorted_set", RangeByScore(InfBound.NEG_INF, ScoreBoundary(3)))
|
|
4496
|
-
[b'member2', b'member3'] # Returns members with scores within the range of negative infinity to 3, in
|
|
4921
|
+
[b'member2', b'member3'] # Returns members with scores within the range of negative infinity to 3, in
|
|
4922
|
+
# ascending order.
|
|
4497
4923
|
"""
|
|
4498
4924
|
args = _create_zrange_args(key, range_query, reverse, with_scores=False)
|
|
4499
4925
|
|
|
@@ -4509,24 +4935,29 @@ class CoreCommands(Protocol):
|
|
|
4509
4935
|
Returns the specified range of elements with their scores in the sorted set stored at `key`.
|
|
4510
4936
|
Similar to ZRANGE but with a WITHSCORE flag.
|
|
4511
4937
|
|
|
4512
|
-
See https://valkey.io/commands/zrange/ for more details.
|
|
4938
|
+
See [valkey.io](https://valkey.io/commands/zrange/) for more details.
|
|
4513
4939
|
|
|
4514
4940
|
Args:
|
|
4515
4941
|
key (TEncodable): The key of the sorted set.
|
|
4516
|
-
range_query (Union[RangeByIndex, RangeByScore]): The range query object representing the type of range query to
|
|
4517
|
-
|
|
4518
|
-
|
|
4942
|
+
range_query (Union[RangeByIndex, RangeByScore]): The range query object representing the type of range query to
|
|
4943
|
+
perform.
|
|
4944
|
+
|
|
4945
|
+
- For range queries by index (rank), use RangeByIndex.
|
|
4946
|
+
- For range queries by score, use RangeByScore.
|
|
4947
|
+
|
|
4519
4948
|
reverse (bool): If True, reverses the sorted set, with index 0 as the element with the highest score.
|
|
4520
4949
|
|
|
4521
4950
|
Returns:
|
|
4522
4951
|
Mapping[bytes , float]: A map of elements and their scores within the specified range.
|
|
4952
|
+
|
|
4523
4953
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns an empty map.
|
|
4524
4954
|
|
|
4525
4955
|
Examples:
|
|
4526
4956
|
>>> await client.zrange_withscores("my_sorted_set", RangeByScore(ScoreBoundary(10), ScoreBoundary(20)))
|
|
4527
4957
|
{b'member1': 10.5, b'member2': 15.2} # Returns members with scores between 10 and 20 with their scores.
|
|
4528
4958
|
>>> await client.zrange_withscores("my_sorted_set", RangeByScore(InfBound.NEG_INF, ScoreBoundary(3)))
|
|
4529
|
-
{b'member4': -2.0, b'member7': 1.5} # Returns members with with scores within the range of negative infinity
|
|
4959
|
+
{b'member4': -2.0, b'member7': 1.5} # Returns members with with scores within the range of negative infinity
|
|
4960
|
+
# to 3, with their scores.
|
|
4530
4961
|
"""
|
|
4531
4962
|
args = _create_zrange_args(key, range_query, reverse, with_scores=True)
|
|
4532
4963
|
|
|
@@ -4548,7 +4979,7 @@ class CoreCommands(Protocol):
|
|
|
4548
4979
|
ZRANGESTORE can perform different types of range queries: by index (rank), by the score, or by lexicographical
|
|
4549
4980
|
order.
|
|
4550
4981
|
|
|
4551
|
-
See https://valkey.io/commands/zrangestore for more details.
|
|
4982
|
+
See [valkey.io](https://valkey.io/commands/zrangestore) for more details.
|
|
4552
4983
|
|
|
4553
4984
|
Note:
|
|
4554
4985
|
When in Cluster mode, `source` and `destination` must map to the same hash slot.
|
|
@@ -4556,10 +4987,13 @@ class CoreCommands(Protocol):
|
|
|
4556
4987
|
Args:
|
|
4557
4988
|
destination (TEncodable): The key for the destination sorted set.
|
|
4558
4989
|
source (TEncodable): The key of the source sorted set.
|
|
4559
|
-
range_query (Union[RangeByIndex, RangeByLex, RangeByScore]): The range query object representing the type of range
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4990
|
+
range_query (Union[RangeByIndex, RangeByLex, RangeByScore]): The range query object representing the type of range
|
|
4991
|
+
query to perform.
|
|
4992
|
+
|
|
4993
|
+
- For range queries by index (rank), use RangeByIndex.
|
|
4994
|
+
- For range queries by lexicographical order, use RangeByLex.
|
|
4995
|
+
- For range queries by score, use RangeByScore.
|
|
4996
|
+
|
|
4563
4997
|
reverse (bool): If True, reverses the sorted set, with index 0 as the element with the highest score.
|
|
4564
4998
|
|
|
4565
4999
|
Returns:
|
|
@@ -4567,9 +5001,11 @@ class CoreCommands(Protocol):
|
|
|
4567
5001
|
|
|
4568
5002
|
Examples:
|
|
4569
5003
|
>>> await client.zrangestore("destination_key", "my_sorted_set", RangeByIndex(0, 2), True)
|
|
4570
|
-
3 # The 3 members with the highest scores from "my_sorted_set" were stored in the sorted set at
|
|
5004
|
+
3 # The 3 members with the highest scores from "my_sorted_set" were stored in the sorted set at
|
|
5005
|
+
# "destination_key".
|
|
4571
5006
|
>>> await client.zrangestore("destination_key", "my_sorted_set", RangeByScore(InfBound.NEG_INF, ScoreBoundary(3)))
|
|
4572
|
-
2 # The 2 members with scores between negative infinity and 3 (inclusive) from "my_sorted_set" were stored in
|
|
5007
|
+
2 # The 2 members with scores between negative infinity and 3 (inclusive) from "my_sorted_set" were stored in
|
|
5008
|
+
# the sorted set at "destination_key".
|
|
4573
5009
|
"""
|
|
4574
5010
|
args = _create_zrange_args(source, range_query, reverse, False, destination)
|
|
4575
5011
|
|
|
@@ -4583,7 +5019,7 @@ class CoreCommands(Protocol):
|
|
|
4583
5019
|
"""
|
|
4584
5020
|
Returns the rank of `member` in the sorted set stored at `key`, with scores ordered from low to high.
|
|
4585
5021
|
|
|
4586
|
-
See https://valkey.io/commands/zrank for more details.
|
|
5022
|
+
See [valkey.io](https://valkey.io/commands/zrank) for more details.
|
|
4587
5023
|
|
|
4588
5024
|
To get the rank of `member` with its score, see `zrank_withscore`.
|
|
4589
5025
|
|
|
@@ -4593,9 +5029,10 @@ class CoreCommands(Protocol):
|
|
|
4593
5029
|
|
|
4594
5030
|
Returns:
|
|
4595
5031
|
Optional[int]: The rank of `member` in the sorted set.
|
|
5032
|
+
|
|
4596
5033
|
If `key` doesn't exist, or if `member` is not present in the set, None will be returned.
|
|
4597
5034
|
|
|
4598
|
-
|
|
5035
|
+
Examples:
|
|
4599
5036
|
>>> await client.zrank("my_sorted_set", "member2")
|
|
4600
5037
|
1 # Indicates that "member2" has the second-lowest score in the sorted set "my_sorted_set".
|
|
4601
5038
|
>>> await client.zrank("my_sorted_set", "non_existing_member")
|
|
@@ -4611,9 +5048,10 @@ class CoreCommands(Protocol):
|
|
|
4611
5048
|
member: TEncodable,
|
|
4612
5049
|
) -> Optional[List[Union[int, float]]]:
|
|
4613
5050
|
"""
|
|
4614
|
-
Returns the rank of `member` in the sorted set stored at `key` with its score, where scores are ordered from the
|
|
5051
|
+
Returns the rank of `member` in the sorted set stored at `key` with its score, where scores are ordered from the
|
|
5052
|
+
lowest to highest.
|
|
4615
5053
|
|
|
4616
|
-
See https://valkey.io/commands/zrank for more details.
|
|
5054
|
+
See [valkey.io](https://valkey.io/commands/zrank) for more details.
|
|
4617
5055
|
|
|
4618
5056
|
Args:
|
|
4619
5057
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4621,11 +5059,13 @@ class CoreCommands(Protocol):
|
|
|
4621
5059
|
|
|
4622
5060
|
Returns:
|
|
4623
5061
|
Optional[List[Union[int, float]]]: A list containing the rank and score of `member` in the sorted set.
|
|
5062
|
+
|
|
4624
5063
|
If `key` doesn't exist, or if `member` is not present in the set, None will be returned.
|
|
4625
5064
|
|
|
4626
5065
|
Examples:
|
|
4627
5066
|
>>> await client.zrank_withscore("my_sorted_set", "member2")
|
|
4628
|
-
[1 , 6.0] # Indicates that "member2" with score 6.0 has the second-lowest score in the sorted set
|
|
5067
|
+
[1 , 6.0] # Indicates that "member2" with score 6.0 has the second-lowest score in the sorted set
|
|
5068
|
+
# "my_sorted_set".
|
|
4629
5069
|
>>> await client.zrank_withscore("my_sorted_set", "non_existing_member")
|
|
4630
5070
|
None # Indicates that "non_existing_member" is not present in the sorted set "my_sorted_set".
|
|
4631
5071
|
|
|
@@ -4643,7 +5083,7 @@ class CoreCommands(Protocol):
|
|
|
4643
5083
|
|
|
4644
5084
|
To get the rank of `member` with its score, see `zrevrank_withscore`.
|
|
4645
5085
|
|
|
4646
|
-
See https://valkey.io/commands/zrevrank for more details.
|
|
5086
|
+
See [valkey.io](https://valkey.io/commands/zrevrank) for more details.
|
|
4647
5087
|
|
|
4648
5088
|
Args:
|
|
4649
5089
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4651,7 +5091,8 @@ class CoreCommands(Protocol):
|
|
|
4651
5091
|
|
|
4652
5092
|
Returns:
|
|
4653
5093
|
Optional[int]: The rank of `member` in the sorted set, where ranks are ordered from high to low based on scores.
|
|
4654
|
-
|
|
5094
|
+
|
|
5095
|
+
If `key` doesn't exist, or if `member` is not present in the set, `None` will be returned.
|
|
4655
5096
|
|
|
4656
5097
|
Examples:
|
|
4657
5098
|
>>> await client.zadd("my_sorted_set", {"member1": 10.5, "member2": 8.2, "member3": 9.6})
|
|
@@ -4670,7 +5111,7 @@ class CoreCommands(Protocol):
|
|
|
4670
5111
|
Returns the rank of `member` in the sorted set stored at `key` with its score, where scores are ordered from the
|
|
4671
5112
|
highest to lowest, starting from `0`.
|
|
4672
5113
|
|
|
4673
|
-
See https://valkey.io/commands/zrevrank for more details.
|
|
5114
|
+
See [valkey.io](https://valkey.io/commands/zrevrank) for more details.
|
|
4674
5115
|
|
|
4675
5116
|
Args:
|
|
4676
5117
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4678,8 +5119,9 @@ class CoreCommands(Protocol):
|
|
|
4678
5119
|
|
|
4679
5120
|
Returns:
|
|
4680
5121
|
Optional[List[Union[int, float]]]: A list containing the rank (as `int`) and score (as `float`) of `member`
|
|
4681
|
-
|
|
4682
|
-
|
|
5122
|
+
in the sorted set, where ranks are ordered from high to low based on scores.
|
|
5123
|
+
|
|
5124
|
+
If `key` doesn't exist, or if `member` is not present in the set, `None` will be returned.
|
|
4683
5125
|
|
|
4684
5126
|
Examples:
|
|
4685
5127
|
>>> await client.zadd("my_sorted_set", {"member1": 10.5, "member2": 8.2, "member3": 9.6})
|
|
@@ -4704,7 +5146,7 @@ class CoreCommands(Protocol):
|
|
|
4704
5146
|
Removes the specified members from the sorted set stored at `key`.
|
|
4705
5147
|
Specified members that are not a member of this set are ignored.
|
|
4706
5148
|
|
|
4707
|
-
See https://valkey.io/commands/zrem/ for more details.
|
|
5149
|
+
See [valkey.io](https://valkey.io/commands/zrem/) for more details.
|
|
4708
5150
|
|
|
4709
5151
|
Args:
|
|
4710
5152
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4712,6 +5154,7 @@ class CoreCommands(Protocol):
|
|
|
4712
5154
|
|
|
4713
5155
|
Returns:
|
|
4714
5156
|
int: The number of members that were removed from the sorted set, not including non-existing members.
|
|
5157
|
+
|
|
4715
5158
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
4716
5159
|
|
|
4717
5160
|
Examples:
|
|
@@ -4734,7 +5177,7 @@ class CoreCommands(Protocol):
|
|
|
4734
5177
|
"""
|
|
4735
5178
|
Removes all elements in the sorted set stored at `key` with a score between `min_score` and `max_score`.
|
|
4736
5179
|
|
|
4737
|
-
See https://valkey.io/commands/zremrangebyscore/ for more details.
|
|
5180
|
+
See [valkey.io](https://valkey.io/commands/zremrangebyscore/) for more details.
|
|
4738
5181
|
|
|
4739
5182
|
Args:
|
|
4740
5183
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4746,23 +5189,30 @@ class CoreCommands(Protocol):
|
|
|
4746
5189
|
or ScoreBoundary representing a specific score and inclusivity.
|
|
4747
5190
|
Returns:
|
|
4748
5191
|
int: The number of members that were removed from the sorted set.
|
|
5192
|
+
|
|
4749
5193
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
5194
|
+
|
|
4750
5195
|
If `min_score` is greater than `max_score`, 0 is returned.
|
|
4751
5196
|
|
|
4752
5197
|
Examples:
|
|
4753
5198
|
>>> await client.zremrangebyscore("my_sorted_set", ScoreBoundary(5.0 , is_inclusive=true) , InfBound.POS_INF)
|
|
4754
|
-
2 # Indicates that 2 members with scores between 5.0 (not exclusive) and +inf have been removed from the
|
|
4755
|
-
|
|
5199
|
+
2 # Indicates that 2 members with scores between 5.0 (not exclusive) and +inf have been removed from the
|
|
5200
|
+
# sorted set "my_sorted_set".
|
|
5201
|
+
>>> await client.zremrangebyscore(
|
|
5202
|
+
... "non_existing_sorted_set",
|
|
5203
|
+
... ScoreBoundary(5.0 , is_inclusive=true),
|
|
5204
|
+
... ScoreBoundary(10.0 , is_inclusive=false)
|
|
5205
|
+
... )
|
|
4756
5206
|
0 # Indicates that no members were removed as the sorted set "non_existing_sorted_set" does not exist.
|
|
4757
5207
|
"""
|
|
4758
5208
|
score_min = (
|
|
4759
5209
|
min_score.value["score_arg"]
|
|
4760
|
-
if
|
|
5210
|
+
if isinstance(min_score, InfBound)
|
|
4761
5211
|
else min_score.value
|
|
4762
5212
|
)
|
|
4763
5213
|
score_max = (
|
|
4764
5214
|
max_score.value["score_arg"]
|
|
4765
|
-
if
|
|
5215
|
+
if isinstance(max_score, InfBound)
|
|
4766
5216
|
else max_score.value
|
|
4767
5217
|
)
|
|
4768
5218
|
|
|
@@ -4783,7 +5233,7 @@ class CoreCommands(Protocol):
|
|
|
4783
5233
|
Removes all elements in the sorted set stored at `key` with a lexicographical order between `min_lex` and
|
|
4784
5234
|
`max_lex`.
|
|
4785
5235
|
|
|
4786
|
-
See https://valkey.io/commands/zremrangebylex/ for more details.
|
|
5236
|
+
See [valkey.io](https://valkey.io/commands/zremrangebylex/) for more details.
|
|
4787
5237
|
|
|
4788
5238
|
Args:
|
|
4789
5239
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4796,20 +5246,23 @@ class CoreCommands(Protocol):
|
|
|
4796
5246
|
|
|
4797
5247
|
Returns:
|
|
4798
5248
|
int: The number of members that were removed from the sorted set.
|
|
4799
|
-
|
|
4800
|
-
|
|
5249
|
+
|
|
5250
|
+
If `key` does not exist, it is treated as an empty sorted set, and the command returns `0`.
|
|
5251
|
+
|
|
5252
|
+
If `min_lex` is greater than `max_lex`, `0` is returned.
|
|
4801
5253
|
|
|
4802
5254
|
Examples:
|
|
4803
5255
|
>>> await client.zremrangebylex("my_sorted_set", LexBoundary("a", is_inclusive=False), LexBoundary("e"))
|
|
4804
|
-
4 # Indicates that 4 members, with lexicographical values ranging from "a" (exclusive) to "e" (inclusive),
|
|
5256
|
+
4 # Indicates that 4 members, with lexicographical values ranging from "a" (exclusive) to "e" (inclusive),
|
|
5257
|
+
# have been removed from "my_sorted_set".
|
|
4805
5258
|
>>> await client.zremrangebylex("non_existing_sorted_set", InfBound.NEG_INF, LexBoundary("e"))
|
|
4806
5259
|
0 # Indicates that no members were removed as the sorted set "non_existing_sorted_set" does not exist.
|
|
4807
5260
|
"""
|
|
4808
5261
|
min_lex_arg = (
|
|
4809
|
-
min_lex.value["lex_arg"] if
|
|
5262
|
+
min_lex.value["lex_arg"] if isinstance(min_lex, InfBound) else min_lex.value
|
|
4810
5263
|
)
|
|
4811
5264
|
max_lex_arg = (
|
|
4812
|
-
max_lex.value["lex_arg"] if
|
|
5265
|
+
max_lex.value["lex_arg"] if isinstance(max_lex, InfBound) else max_lex.value
|
|
4813
5266
|
)
|
|
4814
5267
|
|
|
4815
5268
|
return cast(
|
|
@@ -4830,7 +5283,7 @@ class CoreCommands(Protocol):
|
|
|
4830
5283
|
Both `start` and `end` are zero-based indexes with 0 being the element with the lowest score.
|
|
4831
5284
|
These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score.
|
|
4832
5285
|
|
|
4833
|
-
See https://valkey.io/commands/zremrangebyrank/ for more details.
|
|
5286
|
+
See [valkey.io](https://valkey.io/commands/zremrangebyrank/) for more details.
|
|
4834
5287
|
|
|
4835
5288
|
Args:
|
|
4836
5289
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4839,13 +5292,17 @@ class CoreCommands(Protocol):
|
|
|
4839
5292
|
|
|
4840
5293
|
Returns:
|
|
4841
5294
|
int: The number of elements that were removed.
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
5295
|
+
|
|
5296
|
+
If `start` exceeds the end of the sorted set, or if `start` is greater than `end`, `0` is returned.
|
|
5297
|
+
|
|
5298
|
+
If `end` exceeds the actual end of the sorted set, the range will stop at the actual end of the sorted set.
|
|
5299
|
+
|
|
5300
|
+
If `key` does not exist, `0` is returned.
|
|
4845
5301
|
|
|
4846
5302
|
Examples:
|
|
4847
5303
|
>>> await client.zremrangebyrank("my_sorted_set", 0, 4)
|
|
4848
|
-
5 # Indicates that 5 elements, with ranks ranging from 0 to 4 (inclusive), have been removed from
|
|
5304
|
+
5 # Indicates that 5 elements, with ranks ranging from 0 to 4 (inclusive), have been removed from
|
|
5305
|
+
# "my_sorted_set".
|
|
4849
5306
|
>>> await client.zremrangebyrank("my_sorted_set", 0, 4)
|
|
4850
5307
|
0 # Indicates that nothing was removed.
|
|
4851
5308
|
"""
|
|
@@ -4863,9 +5320,10 @@ class CoreCommands(Protocol):
|
|
|
4863
5320
|
max_lex: Union[InfBound, LexBoundary],
|
|
4864
5321
|
) -> int:
|
|
4865
5322
|
"""
|
|
4866
|
-
Returns the number of members in the sorted set stored at `key` with lexicographical values between `min_lex` and
|
|
5323
|
+
Returns the number of members in the sorted set stored at `key` with lexicographical values between `min_lex` and
|
|
5324
|
+
`max_lex`.
|
|
4867
5325
|
|
|
4868
|
-
See https://valkey.io/commands/zlexcount/ for more details.
|
|
5326
|
+
See [valkey.io](https://valkey.io/commands/zlexcount/) for more details.
|
|
4869
5327
|
|
|
4870
5328
|
Args:
|
|
4871
5329
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4878,20 +5336,28 @@ class CoreCommands(Protocol):
|
|
|
4878
5336
|
|
|
4879
5337
|
Returns:
|
|
4880
5338
|
int: The number of members in the specified lexicographical range.
|
|
4881
|
-
|
|
4882
|
-
|
|
5339
|
+
|
|
5340
|
+
If `key` does not exist, it is treated as an empty sorted set, and the command returns `0`.
|
|
5341
|
+
|
|
5342
|
+
If `max_lex < min_lex`, `0` is returned.
|
|
4883
5343
|
|
|
4884
5344
|
Examples:
|
|
4885
5345
|
>>> await client.zlexcount("my_sorted_set", LexBoundary("c" , is_inclusive=True), InfBound.POS_INF)
|
|
4886
|
-
2 # Indicates that there are 2 members with lexicographical values between "c" (inclusive) and positive
|
|
4887
|
-
|
|
4888
|
-
|
|
5346
|
+
2 # Indicates that there are 2 members with lexicographical values between "c" (inclusive) and positive
|
|
5347
|
+
# infinity in the sorted set "my_sorted_set".
|
|
5348
|
+
>>> await client.zlexcount(
|
|
5349
|
+
... "my_sorted_set",
|
|
5350
|
+
... LexBoundary("c" , is_inclusive=True),
|
|
5351
|
+
... LexBoundary("k" , is_inclusive=False)
|
|
5352
|
+
... )
|
|
5353
|
+
1 # Indicates that there is one member with LexBoundary "c" <= lexicographical value < "k" in the sorted set
|
|
5354
|
+
# "my_sorted_set".
|
|
4889
5355
|
"""
|
|
4890
5356
|
min_lex_arg = (
|
|
4891
|
-
min_lex.value["lex_arg"] if
|
|
5357
|
+
min_lex.value["lex_arg"] if isinstance(min_lex, InfBound) else min_lex.value
|
|
4892
5358
|
)
|
|
4893
5359
|
max_lex_arg = (
|
|
4894
|
-
max_lex.value["lex_arg"] if
|
|
5360
|
+
max_lex.value["lex_arg"] if isinstance(max_lex, InfBound) else max_lex.value
|
|
4895
5361
|
)
|
|
4896
5362
|
|
|
4897
5363
|
return cast(
|
|
@@ -4905,7 +5371,7 @@ class CoreCommands(Protocol):
|
|
|
4905
5371
|
"""
|
|
4906
5372
|
Returns the score of `member` in the sorted set stored at `key`.
|
|
4907
5373
|
|
|
4908
|
-
See https://valkey.io/commands/zscore/ for more details.
|
|
5374
|
+
See [valkey.io](https://valkey.io/commands/zscore/) for more details.
|
|
4909
5375
|
|
|
4910
5376
|
Args:
|
|
4911
5377
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4913,7 +5379,9 @@ class CoreCommands(Protocol):
|
|
|
4913
5379
|
|
|
4914
5380
|
Returns:
|
|
4915
5381
|
Optional[float]: The score of the member.
|
|
5382
|
+
|
|
4916
5383
|
If `member` does not exist in the sorted set, None is returned.
|
|
5384
|
+
|
|
4917
5385
|
If `key` does not exist, None is returned.
|
|
4918
5386
|
|
|
4919
5387
|
Examples:
|
|
@@ -4935,7 +5403,7 @@ class CoreCommands(Protocol):
|
|
|
4935
5403
|
"""
|
|
4936
5404
|
Returns the scores associated with the specified `members` in the sorted set stored at `key`.
|
|
4937
5405
|
|
|
4938
|
-
See https://valkey.io/commands/zmscore for more details.
|
|
5406
|
+
See [valkey.io](https://valkey.io/commands/zmscore) for more details.
|
|
4939
5407
|
|
|
4940
5408
|
Args:
|
|
4941
5409
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4943,7 +5411,8 @@ class CoreCommands(Protocol):
|
|
|
4943
5411
|
|
|
4944
5412
|
Returns:
|
|
4945
5413
|
List[Optional[float]]: A list of scores corresponding to `members`.
|
|
4946
|
-
|
|
5414
|
+
|
|
5415
|
+
If a member does not exist in the sorted set, the corresponding value in the list will be None.
|
|
4947
5416
|
|
|
4948
5417
|
Examples:
|
|
4949
5418
|
>>> await client.zmscore("my_sorted_set", ["one", "non_existent_member", "three"])
|
|
@@ -4959,17 +5428,19 @@ class CoreCommands(Protocol):
|
|
|
4959
5428
|
Returns the difference between the first sorted set and all the successive sorted sets.
|
|
4960
5429
|
To get the elements with their scores, see `zdiff_withscores`.
|
|
4961
5430
|
|
|
4962
|
-
|
|
5431
|
+
Note:
|
|
5432
|
+
When in Cluster mode, all keys must map to the same hash slot.
|
|
4963
5433
|
|
|
4964
|
-
See https://valkey.io/commands/zdiff for more details.
|
|
5434
|
+
See [valkey.io](https://valkey.io/commands/zdiff) for more details.
|
|
4965
5435
|
|
|
4966
5436
|
Args:
|
|
4967
5437
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
4968
5438
|
|
|
4969
5439
|
Returns:
|
|
4970
5440
|
List[bytes]: A list of elements representing the difference between the sorted sets.
|
|
4971
|
-
|
|
4972
|
-
|
|
5441
|
+
|
|
5442
|
+
If the first key does not exist, it is treated as an empty sorted set, and the command returns an
|
|
5443
|
+
empty list.
|
|
4973
5444
|
|
|
4974
5445
|
Examples:
|
|
4975
5446
|
>>> await client.zadd("sorted_set1", {"element1":1.0, "element2": 2.0, "element3": 3.0})
|
|
@@ -4988,18 +5459,21 @@ class CoreCommands(Protocol):
|
|
|
4988
5459
|
async def zdiff_withscores(self, keys: List[TEncodable]) -> Mapping[bytes, float]:
|
|
4989
5460
|
"""
|
|
4990
5461
|
Returns the difference between the first sorted set and all the successive sorted sets, with the associated scores.
|
|
4991
|
-
When in Cluster mode, all keys must map to the same hash slot.
|
|
4992
5462
|
|
|
4993
|
-
|
|
5463
|
+
Note:
|
|
5464
|
+
When in Cluster mode, all keys must map to the same hash slot.
|
|
5465
|
+
|
|
5466
|
+
See [valkey.io](https://valkey.io/commands/zdiff) for more details.
|
|
4994
5467
|
|
|
4995
5468
|
Args:
|
|
4996
5469
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
4997
5470
|
|
|
4998
5471
|
Returns:
|
|
4999
5472
|
Mapping[bytes, float]: A mapping of elements and their scores representing the difference between the sorted
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5473
|
+
sets.
|
|
5474
|
+
|
|
5475
|
+
If the first `key` does not exist, it is treated as an empty sorted set, and the command returns an
|
|
5476
|
+
empty list.
|
|
5003
5477
|
|
|
5004
5478
|
Examples:
|
|
5005
5479
|
>>> await client.zadd("sorted_set1", {"element1":1.0, "element2": 2.0, "element3": 3.0})
|
|
@@ -5020,11 +5494,12 @@ class CoreCommands(Protocol):
|
|
|
5020
5494
|
Calculates the difference between the first sorted set and all the successive sorted sets at `keys` and stores
|
|
5021
5495
|
the difference as a sorted set to `destination`, overwriting it if it already exists. Non-existent keys are
|
|
5022
5496
|
treated as empty sets.
|
|
5023
|
-
See https://valkey.io/commands/zdiffstore for more details.
|
|
5024
5497
|
|
|
5025
5498
|
Note:
|
|
5026
5499
|
When in Cluster mode, all keys in `keys` and `destination` must map to the same hash slot.
|
|
5027
5500
|
|
|
5501
|
+
See [valkey.io](https://valkey.io/commands/zdiffstore) for more details.
|
|
5502
|
+
|
|
5028
5503
|
Args:
|
|
5029
5504
|
destination (TEncodable): The key for the resulting sorted set.
|
|
5030
5505
|
keys (List[TEncodable]): The keys of the sorted sets to compare.
|
|
@@ -5058,9 +5533,10 @@ class CoreCommands(Protocol):
|
|
|
5058
5533
|
To get the scores as well, see `zinter_withscores`.
|
|
5059
5534
|
To store the result in a key as a sorted set, see `zinterstore`.
|
|
5060
5535
|
|
|
5061
|
-
|
|
5536
|
+
Note:
|
|
5537
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5062
5538
|
|
|
5063
|
-
See https://valkey.io/commands/zinter/ for more details.
|
|
5539
|
+
See [valkey.io](https://valkey.io/commands/zinter/) for more details.
|
|
5064
5540
|
|
|
5065
5541
|
Args:
|
|
5066
5542
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -5087,18 +5563,22 @@ class CoreCommands(Protocol):
|
|
|
5087
5563
|
aggregation_type: Optional[AggregationType] = None,
|
|
5088
5564
|
) -> Mapping[bytes, float]:
|
|
5089
5565
|
"""
|
|
5090
|
-
Computes the intersection of sorted sets given by the specified `keys` and returns a sorted set of intersecting
|
|
5566
|
+
Computes the intersection of sorted sets given by the specified `keys` and returns a sorted set of intersecting
|
|
5567
|
+
elements with scores.
|
|
5091
5568
|
To get the elements only, see `zinter`.
|
|
5092
5569
|
To store the result in a key as a sorted set, see `zinterstore`.
|
|
5093
5570
|
|
|
5094
|
-
|
|
5571
|
+
Note:
|
|
5572
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5095
5573
|
|
|
5096
|
-
See https://valkey.io/commands/zinter/ for more details.
|
|
5574
|
+
See [valkey.io](https://valkey.io/commands/zinter/) for more details.
|
|
5097
5575
|
|
|
5098
5576
|
Args:
|
|
5099
5577
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5100
|
-
|
|
5101
|
-
List[
|
|
5578
|
+
|
|
5579
|
+
- List[TEncodable] - for keys only.
|
|
5580
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5581
|
+
|
|
5102
5582
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5103
5583
|
when combining the scores of elements. See `AggregationType`.
|
|
5104
5584
|
|
|
@@ -5131,15 +5611,18 @@ class CoreCommands(Protocol):
|
|
|
5131
5611
|
If `destination` already exists, it is overwritten. Otherwise, a new sorted set will be created.
|
|
5132
5612
|
To get the result directly, see `zinter_withscores`.
|
|
5133
5613
|
|
|
5134
|
-
|
|
5614
|
+
Note:
|
|
5615
|
+
When in cluster mode, `destination` and all keys in `keys` must map to the same hash slot.
|
|
5135
5616
|
|
|
5136
|
-
See https://valkey.io/commands/zinterstore/ for more details.
|
|
5617
|
+
See [valkey.io](https://valkey.io/commands/zinterstore/) for more details.
|
|
5137
5618
|
|
|
5138
5619
|
Args:
|
|
5139
5620
|
destination (TEncodable): The key of the destination sorted set.
|
|
5140
5621
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5141
|
-
|
|
5142
|
-
List[
|
|
5622
|
+
|
|
5623
|
+
- List[TEncodable] - for keys only.
|
|
5624
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5625
|
+
|
|
5143
5626
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5144
5627
|
when combining the scores of elements. See `AggregationType`.
|
|
5145
5628
|
|
|
@@ -5154,7 +5637,8 @@ class CoreCommands(Protocol):
|
|
|
5154
5637
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5155
5638
|
{b'member1': 20} # "member1" is now stored in "my_sorted_set" with score of 20.
|
|
5156
5639
|
>>> await client.zinterstore("my_sorted_set", ["key1", "key2"], AggregationType.MAX)
|
|
5157
|
-
1 # Indicates that the sorted set "my_sorted_set" contains one element, and its score is the maximum score
|
|
5640
|
+
1 # Indicates that the sorted set "my_sorted_set" contains one element, and its score is the maximum score
|
|
5641
|
+
# between the sets.
|
|
5158
5642
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5159
5643
|
{b'member1': 10.5} # "member1" is now stored in "my_sorted_set" with score of 10.5.
|
|
5160
5644
|
"""
|
|
@@ -5173,9 +5657,10 @@ class CoreCommands(Protocol):
|
|
|
5173
5657
|
To get the scores as well, see `zunion_withscores`.
|
|
5174
5658
|
To store the result in a key as a sorted set, see `zunionstore`.
|
|
5175
5659
|
|
|
5176
|
-
|
|
5660
|
+
Note:
|
|
5661
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5177
5662
|
|
|
5178
|
-
See https://valkey.io/commands/zunion/ for more details.
|
|
5663
|
+
See [valkey.io](https://valkey.io/commands/zunion/) for more details.
|
|
5179
5664
|
|
|
5180
5665
|
Args:
|
|
5181
5666
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -5206,14 +5691,17 @@ class CoreCommands(Protocol):
|
|
|
5206
5691
|
To get the elements only, see `zunion`.
|
|
5207
5692
|
To store the result in a key as a sorted set, see `zunionstore`.
|
|
5208
5693
|
|
|
5209
|
-
|
|
5694
|
+
Note:
|
|
5695
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5210
5696
|
|
|
5211
|
-
See https://valkey.io/commands/zunion/ for more details.
|
|
5697
|
+
See [valkey.io](https://valkey.io/commands/zunion/) for more details.
|
|
5212
5698
|
|
|
5213
5699
|
Args:
|
|
5214
5700
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5215
|
-
|
|
5216
|
-
List[
|
|
5701
|
+
|
|
5702
|
+
- List[TEncodable] - for keys only.
|
|
5703
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5704
|
+
|
|
5217
5705
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5218
5706
|
when combining the scores of elements. See `AggregationType`.
|
|
5219
5707
|
|
|
@@ -5246,15 +5734,18 @@ class CoreCommands(Protocol):
|
|
|
5246
5734
|
If `destination` already exists, it is overwritten. Otherwise, a new sorted set will be created.
|
|
5247
5735
|
To get the result directly, see `zunion_withscores`.
|
|
5248
5736
|
|
|
5249
|
-
|
|
5737
|
+
Note:
|
|
5738
|
+
When in cluster mode, `destination` and all keys in `keys` must map to the same hash slot.
|
|
5250
5739
|
|
|
5251
|
-
See https://valkey.io/commands/zunionstore/ for more details.
|
|
5740
|
+
See [valkey.io](https://valkey.io/commands/zunionstore/) for more details.
|
|
5252
5741
|
|
|
5253
5742
|
Args:
|
|
5254
5743
|
destination (TEncodable): The key of the destination sorted set.
|
|
5255
5744
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5256
|
-
|
|
5257
|
-
List[
|
|
5745
|
+
|
|
5746
|
+
- List[TEncodable] - for keys only.
|
|
5747
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5748
|
+
|
|
5258
5749
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5259
5750
|
when combining the scores of elements. See `AggregationType`.
|
|
5260
5751
|
|
|
@@ -5269,7 +5760,8 @@ class CoreCommands(Protocol):
|
|
|
5269
5760
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5270
5761
|
{b'member1': 20, b'member2': 8.2}
|
|
5271
5762
|
>>> await client.zunionstore("my_sorted_set", ["key1", "key2"], AggregationType.MAX)
|
|
5272
|
-
2 # Indicates that the sorted set "my_sorted_set" contains two elements, and each score is the maximum score
|
|
5763
|
+
2 # Indicates that the sorted set "my_sorted_set" contains two elements, and each score is the maximum score
|
|
5764
|
+
# between the sets.
|
|
5273
5765
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5274
5766
|
{b'member1': 10.5, b'member2': 8.2}
|
|
5275
5767
|
"""
|
|
@@ -5283,14 +5775,15 @@ class CoreCommands(Protocol):
|
|
|
5283
5775
|
"""
|
|
5284
5776
|
Returns a random member from the sorted set stored at 'key'.
|
|
5285
5777
|
|
|
5286
|
-
See https://valkey.io/commands/zrandmember for more details.
|
|
5778
|
+
See [valkey.io](https://valkey.io/commands/zrandmember) for more details.
|
|
5287
5779
|
|
|
5288
5780
|
Args:
|
|
5289
5781
|
key (TEncodable): The key of the sorted set.
|
|
5290
5782
|
|
|
5291
5783
|
Returns:
|
|
5292
5784
|
Optional[bytes]: A random member from the sorted set.
|
|
5293
|
-
|
|
5785
|
+
|
|
5786
|
+
If the sorted set does not exist or is empty, the response will be None.
|
|
5294
5787
|
|
|
5295
5788
|
Examples:
|
|
5296
5789
|
>>> await client.zadd("my_sorted_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -5299,7 +5792,6 @@ class CoreCommands(Protocol):
|
|
|
5299
5792
|
>>> await client.zrandmember("non_existing_sorted_set")
|
|
5300
5793
|
None # "non_existing_sorted_set" is not an existing key, so None was returned.
|
|
5301
5794
|
"""
|
|
5302
|
-
args: List[TEncodable] = [key]
|
|
5303
5795
|
return cast(
|
|
5304
5796
|
Optional[bytes],
|
|
5305
5797
|
await self._execute_command(RequestType.ZRandMember, [key]),
|
|
@@ -5309,17 +5801,19 @@ class CoreCommands(Protocol):
|
|
|
5309
5801
|
"""
|
|
5310
5802
|
Retrieves up to the absolute value of `count` random members from the sorted set stored at 'key'.
|
|
5311
5803
|
|
|
5312
|
-
See https://valkey.io/commands/zrandmember for more details.
|
|
5804
|
+
See [valkey.io](https://valkey.io/commands/zrandmember) for more details.
|
|
5313
5805
|
|
|
5314
5806
|
Args:
|
|
5315
5807
|
key (TEncodable): The key of the sorted set.
|
|
5316
5808
|
count (int): The number of members to return.
|
|
5317
|
-
|
|
5318
|
-
If `count` is
|
|
5809
|
+
|
|
5810
|
+
- If `count` is positive, returns unique members.
|
|
5811
|
+
- If `count` is negative, allows for duplicates members.
|
|
5319
5812
|
|
|
5320
5813
|
Returns:
|
|
5321
5814
|
List[bytes]: A list of members from the sorted set.
|
|
5322
|
-
|
|
5815
|
+
|
|
5816
|
+
If the sorted set does not exist or is empty, the response will be an empty list.
|
|
5323
5817
|
|
|
5324
5818
|
Examples:
|
|
5325
5819
|
>>> await client.zadd("my_sorted_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -5341,23 +5835,27 @@ class CoreCommands(Protocol):
|
|
|
5341
5835
|
Retrieves up to the absolute value of `count` random members along with their scores from the sorted set
|
|
5342
5836
|
stored at 'key'.
|
|
5343
5837
|
|
|
5344
|
-
See https://valkey.io/commands/zrandmember for more details.
|
|
5838
|
+
See [valkey.io](https://valkey.io/commands/zrandmember) for more details.
|
|
5345
5839
|
|
|
5346
5840
|
Args:
|
|
5347
5841
|
key (TEncodable): The key of the sorted set.
|
|
5348
5842
|
count (int): The number of members to return.
|
|
5349
|
-
|
|
5350
|
-
If `count` is
|
|
5843
|
+
|
|
5844
|
+
- If `count` is positive, returns unique members.
|
|
5845
|
+
- If `count` is negative, allows for duplicates members.
|
|
5351
5846
|
|
|
5352
5847
|
Returns:
|
|
5353
5848
|
List[List[Union[bytes, float]]]: A list of `[member, score]` lists, where `member` is a random member from
|
|
5354
|
-
|
|
5355
|
-
|
|
5849
|
+
the sorted set and `score` is the associated score.
|
|
5850
|
+
|
|
5851
|
+
If the sorted set does not exist or is empty, the response will be an empty list.
|
|
5356
5852
|
|
|
5357
5853
|
Examples:
|
|
5358
5854
|
>>> await client.zadd("my_sorted_set", {"member1": 1.0, "member2": 2.0})
|
|
5359
5855
|
>>> await client.zrandmember_withscores("my_sorted_set", -3)
|
|
5360
|
-
[[b"member1", 1.0], [b"member1", 1.0], [b"member2", 2.0]] # "member1" and "member2" are random members of
|
|
5856
|
+
[[b"member1", 1.0], [b"member1", 1.0], [b"member2", 2.0]] # "member1" and "member2" are random members of
|
|
5857
|
+
# "my_sorted_set", and have scores of 1.0 and 2.0,
|
|
5858
|
+
# respectively.
|
|
5361
5859
|
>>> await client.zrandmember_withscores("non_existing_sorted_set", 3)
|
|
5362
5860
|
[] # "non_existing_sorted_set" is not an existing key, so an empty list was returned.
|
|
5363
5861
|
"""
|
|
@@ -5382,7 +5880,7 @@ class CoreCommands(Protocol):
|
|
|
5382
5880
|
|
|
5383
5881
|
The number of popped elements is the minimum from the sorted set's cardinality and `count`.
|
|
5384
5882
|
|
|
5385
|
-
See https://valkey.io/commands/zmpop for more details.
|
|
5883
|
+
See [valkey.io](https://valkey.io/commands/zmpop) for more details.
|
|
5386
5884
|
|
|
5387
5885
|
Note:
|
|
5388
5886
|
When in cluster mode, all `keys` must map to the same hash slot.
|
|
@@ -5395,14 +5893,16 @@ class CoreCommands(Protocol):
|
|
|
5395
5893
|
|
|
5396
5894
|
Returns:
|
|
5397
5895
|
Optional[List[Union[bytes, Mapping[bytes, float]]]]: A two-element list containing the key name of the set from
|
|
5398
|
-
|
|
5399
|
-
|
|
5896
|
+
which elements were popped, and a member-score mapping of the popped elements.
|
|
5897
|
+
|
|
5898
|
+
If no members could be popped, returns None.
|
|
5400
5899
|
|
|
5401
5900
|
Examples:
|
|
5402
5901
|
>>> await client.zadd("zSet1", {"one": 1.0, "two": 2.0, "three": 3.0})
|
|
5403
5902
|
>>> await client.zadd("zSet2", {"four": 4.0})
|
|
5404
5903
|
>>> await client.zmpop(["zSet1", "zSet2"], ScoreFilter.MAX, 2)
|
|
5405
|
-
[b'zSet1', {b'three': 3.0, b'two': 2.0}] # "three" with score 3.0 and "two" with score 2.0 were
|
|
5904
|
+
[b'zSet1', {b'three': 3.0, b'two': 2.0}] # "three" with score 3.0 and "two" with score 2.0 were
|
|
5905
|
+
# popped from "zSet1".
|
|
5406
5906
|
|
|
5407
5907
|
Since: Valkey version 7.0.0.
|
|
5408
5908
|
"""
|
|
@@ -5432,11 +5932,13 @@ class CoreCommands(Protocol):
|
|
|
5432
5932
|
|
|
5433
5933
|
`BZMPOP` is the blocking variant of `ZMPOP`.
|
|
5434
5934
|
|
|
5435
|
-
See https://valkey.io/commands/bzmpop for more details.
|
|
5935
|
+
See [valkey.io](https://valkey.io/commands/bzmpop) for more details.
|
|
5436
5936
|
|
|
5437
5937
|
Notes:
|
|
5438
5938
|
1. When in cluster mode, all `keys` must map to the same hash slot.
|
|
5439
|
-
2. `BZMPOP` is a client blocking command, see
|
|
5939
|
+
2. `BZMPOP` is a client blocking command, see
|
|
5940
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
5941
|
+
for more details and best practices.
|
|
5440
5942
|
|
|
5441
5943
|
Args:
|
|
5442
5944
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -5448,14 +5950,16 @@ class CoreCommands(Protocol):
|
|
|
5448
5950
|
|
|
5449
5951
|
Returns:
|
|
5450
5952
|
Optional[List[Union[bytes, Mapping[bytes, float]]]]: A two-element list containing the key name of the set from
|
|
5451
|
-
|
|
5452
|
-
|
|
5953
|
+
which elements were popped, and a member-score mapping of the popped elements.
|
|
5954
|
+
|
|
5955
|
+
If no members could be popped and the timeout expired, returns None.
|
|
5453
5956
|
|
|
5454
5957
|
Examples:
|
|
5455
5958
|
>>> await client.zadd("zSet1", {"one": 1.0, "two": 2.0, "three": 3.0})
|
|
5456
5959
|
>>> await client.zadd("zSet2", {"four": 4.0})
|
|
5457
5960
|
>>> await client.bzmpop(["zSet1", "zSet2"], ScoreFilter.MAX, 0.5, 2)
|
|
5458
|
-
[b'zSet1', {b'three': 3.0, b'two': 2.0}] # "three" with score 3.0 and "two" with score 2.0 were
|
|
5961
|
+
[b'zSet1', {b'three': 3.0, b'two': 2.0}] # "three" with score 3.0 and "two" with score 2.0 were
|
|
5962
|
+
# popped from "zSet1".
|
|
5459
5963
|
|
|
5460
5964
|
Since: Valkey version 7.0.0.
|
|
5461
5965
|
"""
|
|
@@ -5476,16 +5980,16 @@ class CoreCommands(Protocol):
|
|
|
5476
5980
|
optional `limit` argument, if the intersection cardinality reaches `limit` partway through the computation, the
|
|
5477
5981
|
algorithm will exit early and yield `limit` as the cardinality.
|
|
5478
5982
|
|
|
5479
|
-
|
|
5983
|
+
Note:
|
|
5984
|
+
When in cluster mode, all `keys` must map to the same hash slot.
|
|
5985
|
+
|
|
5986
|
+
See [valkey.io](https://valkey.io/commands/zintercard) for more details.
|
|
5480
5987
|
|
|
5481
5988
|
Args:
|
|
5482
5989
|
keys (List[TEncodable]): The keys of the sorted sets to intersect.
|
|
5483
5990
|
limit (Optional[int]): An optional argument that can be used to specify a maximum number for the
|
|
5484
5991
|
intersection cardinality. If limit is not supplied, or if it is set to 0, there will be no limit.
|
|
5485
5992
|
|
|
5486
|
-
Note:
|
|
5487
|
-
When in cluster mode, all `keys` must map to the same hash slot.
|
|
5488
|
-
|
|
5489
5993
|
Returns:
|
|
5490
5994
|
int: The cardinality of the intersection of the given sorted sets, or the `limit` if reached.
|
|
5491
5995
|
|
|
@@ -5495,7 +5999,8 @@ class CoreCommands(Protocol):
|
|
|
5495
5999
|
>>> await client.zintercard(["key1", "key2"])
|
|
5496
6000
|
2 # Indicates that the intersection of the sorted sets at "key1" and "key2" has a cardinality of 2.
|
|
5497
6001
|
>>> await client.zintercard(["key1", "key2"], 1)
|
|
5498
|
-
1 # A `limit` of 1 was provided, so the intersection computation exits early and yields the `limit` value
|
|
6002
|
+
1 # A `limit` of 1 was provided, so the intersection computation exits early and yields the `limit` value
|
|
6003
|
+
# of 1.
|
|
5499
6004
|
|
|
5500
6005
|
Since: Valkey version 7.0.0.
|
|
5501
6006
|
"""
|
|
@@ -5512,14 +6017,15 @@ class CoreCommands(Protocol):
|
|
|
5512
6017
|
"""
|
|
5513
6018
|
Returns the original source code of a script in the script cache.
|
|
5514
6019
|
|
|
5515
|
-
See https://valkey.io/commands/script-show for more details.
|
|
6020
|
+
See [valkey.io](https://valkey.io/commands/script-show) for more details.
|
|
5516
6021
|
|
|
5517
6022
|
Args:
|
|
5518
6023
|
sha1 (TEncodable): The SHA1 digest of the script.
|
|
5519
6024
|
|
|
5520
6025
|
Returns:
|
|
5521
6026
|
bytes: The original source code of the script, if present in the cache.
|
|
5522
|
-
|
|
6027
|
+
|
|
6028
|
+
If the script is not found in the cache, an error is thrown.
|
|
5523
6029
|
|
|
5524
6030
|
Example:
|
|
5525
6031
|
>>> await client.script_show(script.get_hash())
|
|
@@ -5535,7 +6041,7 @@ class CoreCommands(Protocol):
|
|
|
5535
6041
|
Creates a new structure if the `key` does not exist.
|
|
5536
6042
|
When no elements are provided, and `key` exists and is a HyperLogLog, then no operation is performed.
|
|
5537
6043
|
|
|
5538
|
-
See https://valkey.io/commands/pfadd/ for more details.
|
|
6044
|
+
See [valkey.io](https://valkey.io/commands/pfadd/) for more details.
|
|
5539
6045
|
|
|
5540
6046
|
Args:
|
|
5541
6047
|
key (TEncodable): The key of the HyperLogLog data structure to add elements into.
|
|
@@ -5543,7 +6049,9 @@ class CoreCommands(Protocol):
|
|
|
5543
6049
|
|
|
5544
6050
|
Returns:
|
|
5545
6051
|
int: If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
|
|
5546
|
-
altered, then returns 1.
|
|
6052
|
+
altered, then returns 1.
|
|
6053
|
+
|
|
6054
|
+
Otherwise, returns 0.
|
|
5547
6055
|
|
|
5548
6056
|
Examples:
|
|
5549
6057
|
>>> await client.pfadd("hll_1", ["a", "b", "c" ])
|
|
@@ -5561,7 +6069,7 @@ class CoreCommands(Protocol):
|
|
|
5561
6069
|
Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or
|
|
5562
6070
|
calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
|
|
5563
6071
|
|
|
5564
|
-
See https://valkey.io/commands/pfcount for more details.
|
|
6072
|
+
See [valkey.io](https://valkey.io/commands/pfcount) for more details.
|
|
5565
6073
|
|
|
5566
6074
|
Note:
|
|
5567
6075
|
When in Cluster mode, all `keys` must map to the same hash slot.
|
|
@@ -5571,7 +6079,8 @@ class CoreCommands(Protocol):
|
|
|
5571
6079
|
|
|
5572
6080
|
Returns:
|
|
5573
6081
|
int: The approximated cardinality of given HyperLogLog data structures.
|
|
5574
|
-
|
|
6082
|
+
|
|
6083
|
+
The cardinality of a key that does not exist is 0.
|
|
5575
6084
|
|
|
5576
6085
|
Examples:
|
|
5577
6086
|
>>> await client.pfcount(["hll_1", "hll_2"])
|
|
@@ -5589,7 +6098,7 @@ class CoreCommands(Protocol):
|
|
|
5589
6098
|
Merges multiple HyperLogLog values into a unique value. If the destination variable exists, it is treated as one
|
|
5590
6099
|
of the source HyperLogLog data sets, otherwise a new HyperLogLog is created.
|
|
5591
6100
|
|
|
5592
|
-
See https://valkey.io/commands/pfmerge for more details.
|
|
6101
|
+
See [valkey.io](https://valkey.io/commands/pfmerge) for more details.
|
|
5593
6102
|
|
|
5594
6103
|
Note:
|
|
5595
6104
|
When in Cluster mode, all keys in `source_keys` and `destination` must map to the same hash slot.
|
|
@@ -5623,7 +6132,7 @@ class CoreCommands(Protocol):
|
|
|
5623
6132
|
Counts the number of set bits (population counting) in the string stored at `key`. The `options` argument can
|
|
5624
6133
|
optionally be provided to count the number of bits in a specific string interval.
|
|
5625
6134
|
|
|
5626
|
-
See https://valkey.io/commands/bitcount for more details.
|
|
6135
|
+
See [valkey.io](https://valkey.io/commands/bitcount) for more details.
|
|
5627
6136
|
|
|
5628
6137
|
Args:
|
|
5629
6138
|
key (TEncodable): The key for the string to count the set bits of.
|
|
@@ -5631,8 +6140,10 @@ class CoreCommands(Protocol):
|
|
|
5631
6140
|
|
|
5632
6141
|
Returns:
|
|
5633
6142
|
int: If `options` is provided, returns the number of set bits in the string interval specified by `options`.
|
|
5634
|
-
|
|
5635
|
-
|
|
6143
|
+
|
|
6144
|
+
If `options` is not provided, returns the number of set bits in the string stored at `key`.
|
|
6145
|
+
|
|
6146
|
+
Otherwise, if `key` is missing, returns `0` as it is treated as an empty string.
|
|
5636
6147
|
|
|
5637
6148
|
Examples:
|
|
5638
6149
|
>>> await client.bitcount("my_key1")
|
|
@@ -5662,7 +6173,7 @@ class CoreCommands(Protocol):
|
|
|
5662
6173
|
than `2^32` and greater than or equal to `0`. If a key is non-existent then the bit at `offset` is set to
|
|
5663
6174
|
`value` and the preceding bits are set to `0`.
|
|
5664
6175
|
|
|
5665
|
-
See https://valkey.io/commands/setbit for more details.
|
|
6176
|
+
See [valkey.io](https://valkey.io/commands/setbit) for more details.
|
|
5666
6177
|
|
|
5667
6178
|
Args:
|
|
5668
6179
|
key (TEncodable): The key of the string.
|
|
@@ -5688,15 +6199,16 @@ class CoreCommands(Protocol):
|
|
|
5688
6199
|
Returns the bit value at `offset` in the string value stored at `key`.
|
|
5689
6200
|
`offset` should be greater than or equal to zero.
|
|
5690
6201
|
|
|
5691
|
-
See https://valkey.io/commands/getbit for more details.
|
|
6202
|
+
See [valkey.io](https://valkey.io/commands/getbit) for more details.
|
|
5692
6203
|
|
|
5693
6204
|
Args:
|
|
5694
6205
|
key (TEncodable): The key of the string.
|
|
5695
6206
|
offset (int): The index of the bit to return.
|
|
5696
6207
|
|
|
5697
6208
|
Returns:
|
|
5698
|
-
int: The bit at the given `offset` of the string.
|
|
5699
|
-
|
|
6209
|
+
int: The bit at the given `offset` of the string.
|
|
6210
|
+
|
|
6211
|
+
Returns `0` if the key is empty or if the `offset` exceeds the length of the string.
|
|
5700
6212
|
|
|
5701
6213
|
Examples:
|
|
5702
6214
|
>>> await client.getbit("my_key", 1)
|
|
@@ -5721,7 +6233,7 @@ class CoreCommands(Protocol):
|
|
|
5721
6233
|
are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is
|
|
5722
6234
|
specified, `start=0` and `end=2` means to look at the first three bytes.
|
|
5723
6235
|
|
|
5724
|
-
See https://valkey.io/commands/bitpos for more details.
|
|
6236
|
+
See [valkey.io](https://valkey.io/commands/bitpos) for more details.
|
|
5725
6237
|
|
|
5726
6238
|
Args:
|
|
5727
6239
|
key (TEncodable): The key of the string.
|
|
@@ -5730,20 +6242,24 @@ class CoreCommands(Protocol):
|
|
|
5730
6242
|
|
|
5731
6243
|
Returns:
|
|
5732
6244
|
int: The position of the first occurrence of `bit` in the binary value of the string held at `key`.
|
|
5733
|
-
|
|
6245
|
+
|
|
6246
|
+
If `start` was provided, the search begins at the offset indicated by `start`.
|
|
5734
6247
|
|
|
5735
6248
|
Examples:
|
|
5736
6249
|
>>> await client.set("key1", "A1") # "A1" has binary value 01000001 00110001
|
|
5737
6250
|
>>> await client.bitpos("key1", 1)
|
|
5738
6251
|
1 # The first occurrence of bit value 1 in the string stored at "key1" is at the second position.
|
|
5739
6252
|
>>> await client.bitpos("key1", 1, OffsetOptions(-1))
|
|
5740
|
-
10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1",
|
|
6253
|
+
10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1",
|
|
6254
|
+
# is at the eleventh position.
|
|
5741
6255
|
|
|
5742
6256
|
>>> await client.set("key2", "A12") # "A12" has binary value 01000001 00110001 00110010
|
|
5743
6257
|
>>> await client.bitpos("key2", 1, OffsetOptions(1, -1))
|
|
5744
|
-
10 # The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1"
|
|
6258
|
+
10 # The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1"
|
|
6259
|
+
# is at the eleventh position.
|
|
5745
6260
|
>>> await client.bitpos("key2", 1, OffsetOptions(2, 9, BitmapIndexType.BIT))
|
|
5746
|
-
7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1"
|
|
6261
|
+
7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1"
|
|
6262
|
+
# is at the eighth position.
|
|
5747
6263
|
"""
|
|
5748
6264
|
args: List[TEncodable] = [key, str(bit)]
|
|
5749
6265
|
if options is not None:
|
|
@@ -5764,7 +6280,7 @@ class CoreCommands(Protocol):
|
|
|
5764
6280
|
Perform a bitwise operation between multiple keys (containing string values) and store the result in the
|
|
5765
6281
|
`destination`.
|
|
5766
6282
|
|
|
5767
|
-
See https://valkey.io/commands/bitop for more details.
|
|
6283
|
+
See [valkey.io](https://valkey.io/commands/bitop) for more details.
|
|
5768
6284
|
|
|
5769
6285
|
Note:
|
|
5770
6286
|
When in cluster mode, `destination` and all `keys` must map to the same hash slot.
|
|
@@ -5799,12 +6315,13 @@ class CoreCommands(Protocol):
|
|
|
5799
6315
|
Reads or modifies the array of bits representing the string that is held at `key` based on the specified
|
|
5800
6316
|
`subcommands`.
|
|
5801
6317
|
|
|
5802
|
-
See https://valkey.io/commands/bitfield for more details.
|
|
6318
|
+
See [valkey.io](https://valkey.io/commands/bitfield) for more details.
|
|
5803
6319
|
|
|
5804
6320
|
Args:
|
|
5805
6321
|
key (TEncodable): The key of the string.
|
|
5806
6322
|
subcommands (List[BitFieldSubCommands]): The subcommands to be performed on the binary value of the string
|
|
5807
6323
|
at `key`, which could be any of the following:
|
|
6324
|
+
|
|
5808
6325
|
- `BitFieldGet`
|
|
5809
6326
|
- `BitFieldSet`
|
|
5810
6327
|
- `BitFieldIncrBy`
|
|
@@ -5812,6 +6329,7 @@ class CoreCommands(Protocol):
|
|
|
5812
6329
|
|
|
5813
6330
|
Returns:
|
|
5814
6331
|
List[Optional[int]]: An array of results from the executed subcommands:
|
|
6332
|
+
|
|
5815
6333
|
- `BitFieldGet` returns the value in `BitOffset` or `BitOffsetMultiplier`.
|
|
5816
6334
|
- `BitFieldSet` returns the old value in `BitOffset` or `BitOffsetMultiplier`.
|
|
5817
6335
|
- `BitFieldIncrBy` returns the new value in `BitOffset` or `BitOffsetMultiplier`.
|
|
@@ -5821,8 +6339,12 @@ class CoreCommands(Protocol):
|
|
|
5821
6339
|
|
|
5822
6340
|
Examples:
|
|
5823
6341
|
>>> await client.set("my_key", "A") # "A" has binary value 01000001
|
|
5824
|
-
>>> await client.bitfield(
|
|
5825
|
-
|
|
6342
|
+
>>> await client.bitfield(
|
|
6343
|
+
... "my_key",
|
|
6344
|
+
... [BitFieldSet(UnsignedEncoding(2), BitOffset(1), 3), BitFieldGet(UnsignedEncoding(2), BitOffset(1))]
|
|
6345
|
+
... )
|
|
6346
|
+
[2, 3] # The old value at offset 1 with an unsigned encoding of 2 was 2. The new value at offset 1 with an
|
|
6347
|
+
# unsigned encoding of 2 is 3.
|
|
5826
6348
|
"""
|
|
5827
6349
|
args = [key] + _create_bitfield_args(subcommands)
|
|
5828
6350
|
return cast(
|
|
@@ -5836,7 +6358,7 @@ class CoreCommands(Protocol):
|
|
|
5836
6358
|
"""
|
|
5837
6359
|
Reads the array of bits representing the string that is held at `key` based on the specified `subcommands`.
|
|
5838
6360
|
|
|
5839
|
-
See https://valkey.io/commands/bitfield_ro for more details.
|
|
6361
|
+
See [valkey.io](https://valkey.io/commands/bitfield_ro) for more details.
|
|
5840
6362
|
|
|
5841
6363
|
Args:
|
|
5842
6364
|
key (TEncodable): The key of the string.
|
|
@@ -5862,14 +6384,16 @@ class CoreCommands(Protocol):
|
|
|
5862
6384
|
"""
|
|
5863
6385
|
Returns the internal encoding for the Valkey object stored at `key`.
|
|
5864
6386
|
|
|
5865
|
-
See https://valkey.io/commands/object-encoding for more details.
|
|
6387
|
+
See [valkey.io](https://valkey.io/commands/object-encoding) for more details.
|
|
5866
6388
|
|
|
5867
6389
|
Args:
|
|
5868
6390
|
key (TEncodable): The `key` of the object to get the internal encoding of.
|
|
5869
6391
|
|
|
5870
6392
|
Returns:
|
|
5871
6393
|
Optional[bytes]: If `key` exists, returns the internal encoding of the object stored at
|
|
5872
|
-
|
|
6394
|
+
`key` as a bytes string.
|
|
6395
|
+
|
|
6396
|
+
Otherwise, returns None.
|
|
5873
6397
|
|
|
5874
6398
|
Examples:
|
|
5875
6399
|
>>> await client.object_encoding("my_hash")
|
|
@@ -5884,14 +6408,16 @@ class CoreCommands(Protocol):
|
|
|
5884
6408
|
"""
|
|
5885
6409
|
Returns the logarithmic access frequency counter of a Valkey object stored at `key`.
|
|
5886
6410
|
|
|
5887
|
-
See https://valkey.io/commands/object-freq for more details.
|
|
6411
|
+
See [valkey.io](https://valkey.io/commands/object-freq) for more details.
|
|
5888
6412
|
|
|
5889
6413
|
Args:
|
|
5890
6414
|
key (TEncodable): The key of the object to get the logarithmic access frequency counter of.
|
|
5891
6415
|
|
|
5892
6416
|
Returns:
|
|
5893
|
-
Optional[int]: If `key` exists, returns the logarithmic access frequency counter of the object stored at `key` as
|
|
5894
|
-
|
|
6417
|
+
Optional[int]: If `key` exists, returns the logarithmic access frequency counter of the object stored at `key` as
|
|
6418
|
+
an integer.
|
|
6419
|
+
|
|
6420
|
+
Otherwise, returns None.
|
|
5895
6421
|
|
|
5896
6422
|
Examples:
|
|
5897
6423
|
>>> await client.object_freq("my_hash")
|
|
@@ -5906,13 +6432,15 @@ class CoreCommands(Protocol):
|
|
|
5906
6432
|
"""
|
|
5907
6433
|
Returns the time in seconds since the last access to the value stored at `key`.
|
|
5908
6434
|
|
|
5909
|
-
See https://valkey.io/commands/object-idletime for more details.
|
|
6435
|
+
See [valkey.io](https://valkey.io/commands/object-idletime) for more details.
|
|
5910
6436
|
|
|
5911
6437
|
Args:
|
|
5912
6438
|
key (TEncodable): The key of the object to get the idle time of.
|
|
5913
6439
|
|
|
5914
6440
|
Returns:
|
|
5915
|
-
Optional[int]: If `key` exists, returns the idle time in seconds.
|
|
6441
|
+
Optional[int]: If `key` exists, returns the idle time in seconds.
|
|
6442
|
+
|
|
6443
|
+
Otherwise, returns None.
|
|
5916
6444
|
|
|
5917
6445
|
Examples:
|
|
5918
6446
|
>>> await client.object_idletime("my_hash")
|
|
@@ -5927,14 +6455,15 @@ class CoreCommands(Protocol):
|
|
|
5927
6455
|
"""
|
|
5928
6456
|
Returns the reference count of the object stored at `key`.
|
|
5929
6457
|
|
|
5930
|
-
See https://valkey.io/commands/object-refcount for more details.
|
|
6458
|
+
See [valkey.io](https://valkey.io/commands/object-refcount) for more details.
|
|
5931
6459
|
|
|
5932
6460
|
Args:
|
|
5933
6461
|
key (TEncodable): The key of the object to get the reference count of.
|
|
5934
6462
|
|
|
5935
6463
|
Returns:
|
|
5936
6464
|
Optional[int]: If `key` exists, returns the reference count of the object stored at `key` as an integer.
|
|
5937
|
-
|
|
6465
|
+
|
|
6466
|
+
Otherwise, returns None.
|
|
5938
6467
|
|
|
5939
6468
|
Examples:
|
|
5940
6469
|
>>> await client.object_refcount("my_hash")
|
|
@@ -5949,13 +6478,15 @@ class CoreCommands(Protocol):
|
|
|
5949
6478
|
"""
|
|
5950
6479
|
Returns a random element from the set value stored at 'key'.
|
|
5951
6480
|
|
|
5952
|
-
See https://valkey.io/commands/srandmember for more details.
|
|
6481
|
+
See [valkey.io](https://valkey.io/commands/srandmember) for more details.
|
|
5953
6482
|
|
|
5954
6483
|
Args:
|
|
5955
6484
|
key (TEncodable): The key from which to retrieve the set member.
|
|
5956
6485
|
|
|
5957
6486
|
Returns:
|
|
5958
|
-
Optional[bytes]: A random element from the set
|
|
6487
|
+
Optional[bytes]: A random element from the set.
|
|
6488
|
+
|
|
6489
|
+
`None` if 'key' does not exist.
|
|
5959
6490
|
|
|
5960
6491
|
Examples:
|
|
5961
6492
|
>>> await client.sadd("my_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -5974,17 +6505,19 @@ class CoreCommands(Protocol):
|
|
|
5974
6505
|
"""
|
|
5975
6506
|
Returns one or more random elements from the set value stored at 'key'.
|
|
5976
6507
|
|
|
5977
|
-
See https://valkey.io/commands/srandmember for more details.
|
|
6508
|
+
See [valkey.io](https://valkey.io/commands/srandmember) for more details.
|
|
5978
6509
|
|
|
5979
6510
|
Args:
|
|
5980
6511
|
key (TEncodable): The key of the sorted set.
|
|
5981
6512
|
count (int): The number of members to return.
|
|
5982
|
-
|
|
5983
|
-
If `count` is
|
|
6513
|
+
|
|
6514
|
+
- If `count` is positive, returns unique members.
|
|
6515
|
+
- If `count` is negative, allows for duplicates members.
|
|
5984
6516
|
|
|
5985
6517
|
Returns:
|
|
5986
6518
|
List[bytes]: A list of members from the set.
|
|
5987
|
-
|
|
6519
|
+
|
|
6520
|
+
If the set does not exist or is empty, the response will be an empty list.
|
|
5988
6521
|
|
|
5989
6522
|
Examples:
|
|
5990
6523
|
>>> await client.sadd("my_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -6005,7 +6538,8 @@ class CoreCommands(Protocol):
|
|
|
6005
6538
|
) -> Optional[bytes]:
|
|
6006
6539
|
"""
|
|
6007
6540
|
Get the value of `key` and optionally set its expiration. `GETEX` is similar to `GET`.
|
|
6008
|
-
|
|
6541
|
+
|
|
6542
|
+
See [valkey.io](https://valkey.io/commands/getex) for more details.
|
|
6009
6543
|
|
|
6010
6544
|
Args:
|
|
6011
6545
|
key (TEncodable): The key to get.
|
|
@@ -6013,9 +6547,9 @@ class CoreCommands(Protocol):
|
|
|
6013
6547
|
Equivalent to [`EX` | `PX` | `EXAT` | `PXAT` | `PERSIST`] in the Valkey API.
|
|
6014
6548
|
|
|
6015
6549
|
Returns:
|
|
6016
|
-
Optional[bytes]:
|
|
6017
|
-
|
|
6018
|
-
|
|
6550
|
+
Optional[bytes]: If `key` exists, return the value stored at `key`
|
|
6551
|
+
|
|
6552
|
+
If `key` does not exist, return `None`
|
|
6019
6553
|
|
|
6020
6554
|
Examples:
|
|
6021
6555
|
>>> await client.set("key", "value")
|
|
@@ -6045,14 +6579,15 @@ class CoreCommands(Protocol):
|
|
|
6045
6579
|
"""
|
|
6046
6580
|
Serialize the value stored at `key` in a Valkey-specific format and return it to the user.
|
|
6047
6581
|
|
|
6048
|
-
See https://valkey.io/commands/dump for more details.
|
|
6582
|
+
See [valkey.io](https://valkey.io/commands/dump) for more details.
|
|
6049
6583
|
|
|
6050
6584
|
Args:
|
|
6051
6585
|
key (TEncodable): The `key` to serialize.
|
|
6052
6586
|
|
|
6053
6587
|
Returns:
|
|
6054
6588
|
Optional[bytes]: The serialized value of the data stored at `key`.
|
|
6055
|
-
|
|
6589
|
+
|
|
6590
|
+
If `key` does not exist, `None` will be returned.
|
|
6056
6591
|
|
|
6057
6592
|
Examples:
|
|
6058
6593
|
>>> await client.dump("key")
|
|
@@ -6079,14 +6614,15 @@ class CoreCommands(Protocol):
|
|
|
6079
6614
|
Create a `key` associated with a `value` that is obtained by deserializing the provided
|
|
6080
6615
|
serialized `value` obtained via `dump`.
|
|
6081
6616
|
|
|
6082
|
-
See https://valkey.io/commands/restore for more details.
|
|
6617
|
+
See [valkey.io](https://valkey.io/commands/restore) for more details.
|
|
6083
6618
|
|
|
6084
|
-
Note:
|
|
6619
|
+
Note:
|
|
6620
|
+
`IDLETIME` and `FREQ` modifiers cannot be set at the same time.
|
|
6085
6621
|
|
|
6086
6622
|
Args:
|
|
6087
6623
|
key (TEncodable): The `key` to create.
|
|
6088
6624
|
ttl (int): The expiry time (in milliseconds). If `0`, the `key` will persist.
|
|
6089
|
-
value (TEncodable) The serialized value to deserialize and assign to `key`.
|
|
6625
|
+
value (TEncodable): The serialized value to deserialize and assign to `key`.
|
|
6090
6626
|
replace (bool): Set to `True` to replace the key if it exists.
|
|
6091
6627
|
absttl (bool): Set to `True` to specify that `ttl` represents an absolute Unix
|
|
6092
6628
|
timestamp (in milliseconds).
|
|
@@ -6132,29 +6668,30 @@ class CoreCommands(Protocol):
|
|
|
6132
6668
|
"""
|
|
6133
6669
|
Iterates incrementally over a set.
|
|
6134
6670
|
|
|
6135
|
-
See https://valkey.io/commands/sscan for more details.
|
|
6671
|
+
See [valkey.io](https://valkey.io/commands/sscan) for more details.
|
|
6136
6672
|
|
|
6137
6673
|
Args:
|
|
6138
6674
|
key (TEncodable): The key of the set.
|
|
6139
6675
|
cursor (TEncodable): The cursor that points to the next iteration of results. A value of "0" indicates the start of
|
|
6140
6676
|
the search.
|
|
6141
6677
|
match (Optional[TEncodable]): The match filter is applied to the result of the command and will only include
|
|
6142
|
-
strings or byte strings that match the pattern specified. If the set is large enough for scan commands to
|
|
6143
|
-
subset of the set then there could be a case where the result is empty although there are
|
|
6144
|
-
match the pattern specified. This is due to the default `COUNT` being `10` which indicates
|
|
6145
|
-
only fetch and match `10` items from the list.
|
|
6678
|
+
strings or byte strings that match the pattern specified. If the set is large enough for scan commands to
|
|
6679
|
+
return only a subset of the set then there could be a case where the result is empty although there are
|
|
6680
|
+
items that match the pattern specified. This is due to the default `COUNT` being `10` which indicates
|
|
6681
|
+
that it will only fetch and match `10` items from the list.
|
|
6146
6682
|
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the set.
|
|
6147
6683
|
`COUNT` could be ignored until the set is large enough for the `SCAN` commands to represent the results
|
|
6148
6684
|
as compact single-allocation packed encoding.
|
|
6149
6685
|
|
|
6150
6686
|
Returns:
|
|
6151
6687
|
List[Union[bytes, List[bytes]]]: An `Array` of the `cursor` and the subset of the set held by `key`.
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6688
|
+
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
|
|
6689
|
+
returned on the last iteration of the set. The second element is always an `Array` of the subset of the
|
|
6690
|
+
set held in `key`.
|
|
6155
6691
|
|
|
6156
6692
|
Examples:
|
|
6157
|
-
|
|
6693
|
+
Assume "key" contains a set with 130 members:
|
|
6694
|
+
|
|
6158
6695
|
>>> result_cursor = "0"
|
|
6159
6696
|
>>> while True:
|
|
6160
6697
|
... result = await client.sscan("key", "0", match="*")
|
|
@@ -6193,16 +6730,16 @@ class CoreCommands(Protocol):
|
|
|
6193
6730
|
"""
|
|
6194
6731
|
Iterates incrementally over a sorted set.
|
|
6195
6732
|
|
|
6196
|
-
See https://valkey.io/commands/zscan for more details.
|
|
6733
|
+
See [valkey.io](https://valkey.io/commands/zscan) for more details.
|
|
6197
6734
|
|
|
6198
6735
|
Args:
|
|
6199
6736
|
key (TEncodable): The key of the sorted set.
|
|
6200
6737
|
cursor (TEncodable): The cursor that points to the next iteration of results. A value of "0" indicates the start of
|
|
6201
6738
|
the search.
|
|
6202
6739
|
match (Optional[TEncodable]): The match filter is applied to the result of the command and will only include
|
|
6203
|
-
strings or byte strings that match the pattern specified. If the sorted set is large enough for scan commands
|
|
6204
|
-
only a subset of the sorted set then there could be a case where the result is empty although there
|
|
6205
|
-
items that match the pattern specified. This is due to the default `COUNT` being `10` which indicates
|
|
6740
|
+
strings or byte strings that match the pattern specified. If the sorted set is large enough for scan commands
|
|
6741
|
+
to return only a subset of the sorted set then there could be a case where the result is empty although there
|
|
6742
|
+
are items that match the pattern specified. This is due to the default `COUNT` being `10` which indicates
|
|
6206
6743
|
that it will only fetch and match `10` items from the list.
|
|
6207
6744
|
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the
|
|
6208
6745
|
sorted set. `COUNT` could be ignored until the sorted set is large enough for the `SCAN` commands to
|
|
@@ -6215,10 +6752,12 @@ class CoreCommands(Protocol):
|
|
|
6215
6752
|
returned on the last iteration of the sorted set. The second element is always an `Array` of the subset
|
|
6216
6753
|
of the sorted set held in `key`. The `Array` in the second element is a flattened series of
|
|
6217
6754
|
`String` pairs, where the value is at even indices and the score is at odd indices.
|
|
6218
|
-
|
|
6755
|
+
|
|
6756
|
+
If `no_scores` is set to `True`, the second element will only contain the members without scores.
|
|
6219
6757
|
|
|
6220
6758
|
Examples:
|
|
6221
|
-
|
|
6759
|
+
Assume "key" contains a sorted set with multiple members:
|
|
6760
|
+
|
|
6222
6761
|
>>> result_cursor = "0"
|
|
6223
6762
|
>>> while True:
|
|
6224
6763
|
... result = await client.zscan("key", "0", match="*", count=5)
|
|
@@ -6235,7 +6774,8 @@ class CoreCommands(Protocol):
|
|
|
6235
6774
|
Cursor: 0
|
|
6236
6775
|
Members: [b'value 55', b'55', b'value 24', b'24', b'value 90', b'90', b'value 113', b'113']
|
|
6237
6776
|
|
|
6238
|
-
|
|
6777
|
+
Using no-score:
|
|
6778
|
+
|
|
6239
6779
|
>>> result_cursor = "0"
|
|
6240
6780
|
>>> while True:
|
|
6241
6781
|
... result = await client.zscan("key", "0", match="*", count=5, no_scores=True)
|
|
@@ -6276,17 +6816,17 @@ class CoreCommands(Protocol):
|
|
|
6276
6816
|
"""
|
|
6277
6817
|
Iterates incrementally over a hash.
|
|
6278
6818
|
|
|
6279
|
-
See https://valkey.io/commands/hscan for more details.
|
|
6819
|
+
See [valkey.io](https://valkey.io/commands/hscan) for more details.
|
|
6280
6820
|
|
|
6281
6821
|
Args:
|
|
6282
6822
|
key (TEncodable): The key of the set.
|
|
6283
6823
|
cursor (TEncodable): The cursor that points to the next iteration of results. A value of "0" indicates the start of
|
|
6284
6824
|
the search.
|
|
6285
6825
|
match (Optional[TEncodable]): The match filter is applied to the result of the command and will only include
|
|
6286
|
-
strings or byte strings that match the pattern specified. If the hash is large enough for scan commands to
|
|
6287
|
-
subset of the hash then there could be a case where the result is empty although there are
|
|
6288
|
-
match the pattern specified. This is due to the default `COUNT` being `10` which indicates that it
|
|
6289
|
-
only fetch and match `10` items from the list.
|
|
6826
|
+
strings or byte strings that match the pattern specified. If the hash is large enough for scan commands to
|
|
6827
|
+
return only a subset of the hash then there could be a case where the result is empty although there are
|
|
6828
|
+
items that match the pattern specified. This is due to the default `COUNT` being `10` which indicates that it
|
|
6829
|
+
will only fetch and match `10` items from the list.
|
|
6290
6830
|
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the hash.
|
|
6291
6831
|
`COUNT` could be ignored until the hash is large enough for the `SCAN` commands to represent the results
|
|
6292
6832
|
as compact single-allocation packed encoding.
|
|
@@ -6294,14 +6834,16 @@ class CoreCommands(Protocol):
|
|
|
6294
6834
|
|
|
6295
6835
|
Returns:
|
|
6296
6836
|
List[Union[bytes, List[bytes]]]: An `Array` of the `cursor` and the subset of the hash held by `key`.
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6837
|
+
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
|
|
6838
|
+
returned on the last iteration of the hash. The second element is always an `Array` of the subset of the
|
|
6839
|
+
hash held in `key`. The `Array` in the second element is a flattened series of `String` pairs,
|
|
6840
|
+
where the value is at even indices and the score is at odd indices.
|
|
6841
|
+
|
|
6842
|
+
If `no_values` is set to `True`, the second element will only contain the fields without the values.
|
|
6302
6843
|
|
|
6303
6844
|
Examples:
|
|
6304
|
-
|
|
6845
|
+
Assume "key" contains a hash with multiple members:
|
|
6846
|
+
|
|
6305
6847
|
>>> result_cursor = "0"
|
|
6306
6848
|
>>> while True:
|
|
6307
6849
|
... result = await client.hscan("key", "0", match="*", count=3)
|
|
@@ -6318,7 +6860,8 @@ class CoreCommands(Protocol):
|
|
|
6318
6860
|
Cursor: 0
|
|
6319
6861
|
Members: [b'field 420', b'value 420', b'field 221', b'value 221']
|
|
6320
6862
|
|
|
6321
|
-
|
|
6863
|
+
Use no-values:
|
|
6864
|
+
|
|
6322
6865
|
>>> result_cursor = "0"
|
|
6323
6866
|
>>> while True:
|
|
6324
6867
|
... result = await client.hscan("key", "0", match="*", count=3, no_values=True)
|
|
@@ -6356,8 +6899,12 @@ class CoreCommands(Protocol):
|
|
|
6356
6899
|
) -> TResult:
|
|
6357
6900
|
"""
|
|
6358
6901
|
Invokes a previously loaded function.
|
|
6359
|
-
|
|
6360
|
-
|
|
6902
|
+
|
|
6903
|
+
See [valkey.io](https://valkey.io/commands/fcall/) for more details.
|
|
6904
|
+
|
|
6905
|
+
Note:
|
|
6906
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
6907
|
+
|
|
6361
6908
|
Args:
|
|
6362
6909
|
function (TEncodable): The function name.
|
|
6363
6910
|
keys (Optional[List[TEncodable]]): A list of keys accessed by the function. To ensure the correct
|
|
@@ -6365,9 +6912,10 @@ class CoreCommands(Protocol):
|
|
|
6365
6912
|
that a function accesses must be explicitly provided as `keys`.
|
|
6366
6913
|
arguments (Optional[List[TEncodable]]): A list of `function` arguments. `Arguments`
|
|
6367
6914
|
should not represent names of keys.
|
|
6915
|
+
|
|
6368
6916
|
Returns:
|
|
6369
|
-
TResult:
|
|
6370
|
-
|
|
6917
|
+
TResult: The invoked function's return value.
|
|
6918
|
+
|
|
6371
6919
|
Example:
|
|
6372
6920
|
>>> await client.fcall("Deep_Thought")
|
|
6373
6921
|
b'new_value' # Returns the function's return value.
|
|
@@ -6395,9 +6943,10 @@ class CoreCommands(Protocol):
|
|
|
6395
6943
|
"""
|
|
6396
6944
|
Invokes a previously loaded read-only function.
|
|
6397
6945
|
|
|
6398
|
-
See https://valkey.io/commands/fcall_ro for more details.
|
|
6946
|
+
See [valkey.io](https://valkey.io/commands/fcall_ro) for more details.
|
|
6399
6947
|
|
|
6400
|
-
|
|
6948
|
+
Note:
|
|
6949
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
6401
6950
|
|
|
6402
6951
|
Args:
|
|
6403
6952
|
function (TEncodable): The function name.
|
|
@@ -6431,11 +6980,11 @@ class CoreCommands(Protocol):
|
|
|
6431
6980
|
|
|
6432
6981
|
async def watch(self, keys: List[TEncodable]) -> TOK:
|
|
6433
6982
|
"""
|
|
6434
|
-
Marks the given keys to be watched for conditional execution of
|
|
6435
|
-
will only execute commands if the watched keys are not modified before execution of the
|
|
6983
|
+
Marks the given keys to be watched for conditional execution of an atomic batch (Transaction).
|
|
6984
|
+
Transactions will only execute commands if the watched keys are not modified before execution of the
|
|
6436
6985
|
transaction.
|
|
6437
6986
|
|
|
6438
|
-
See https://valkey.io/commands/watch for more details.
|
|
6987
|
+
See [valkey.io](https://valkey.io/commands/watch) for more details.
|
|
6439
6988
|
|
|
6440
6989
|
Note:
|
|
6441
6990
|
In cluster mode, if keys in `key_value_map` map to different hash slots,
|
|
@@ -6492,10 +7041,11 @@ class CoreCommands(Protocol):
|
|
|
6492
7041
|
"""
|
|
6493
7042
|
Returns the next pubsub message.
|
|
6494
7043
|
Throws WrongConfiguration in cases:
|
|
6495
|
-
1. No pubsub subscriptions are configured for the client
|
|
6496
|
-
2. Callback is configured with the pubsub subsciptions
|
|
6497
7044
|
|
|
6498
|
-
|
|
7045
|
+
1. No pubsub subscriptions are configured for the client
|
|
7046
|
+
2. Callback is configured with the pubsub subsciptions
|
|
7047
|
+
|
|
7048
|
+
See [valkey.io](https://valkey.io/docs/topics/pubsub/) for more details.
|
|
6499
7049
|
|
|
6500
7050
|
Returns:
|
|
6501
7051
|
PubSubMsg: The next pubsub message
|
|
@@ -6509,10 +7059,11 @@ class CoreCommands(Protocol):
|
|
|
6509
7059
|
"""
|
|
6510
7060
|
Tries to return the next pubsub message.
|
|
6511
7061
|
Throws WrongConfiguration in cases:
|
|
6512
|
-
1. No pubsub subscriptions are configured for the client
|
|
6513
|
-
2. Callback is configured with the pubsub subsciptions
|
|
6514
7062
|
|
|
6515
|
-
|
|
7063
|
+
1. No pubsub subscriptions are configured for the client
|
|
7064
|
+
2. Callback is configured with the pubsub subsciptions
|
|
7065
|
+
|
|
7066
|
+
See [valkey.io](https://valkey.io/docs/topics/pubsub/) for more details.
|
|
6516
7067
|
|
|
6517
7068
|
Returns:
|
|
6518
7069
|
Optional[PubSubMsg]: The next pubsub message or None
|
|
@@ -6530,20 +7081,22 @@ class CoreCommands(Protocol):
|
|
|
6530
7081
|
"""
|
|
6531
7082
|
Returns the longest common subsequence between strings stored at key1 and key2.
|
|
6532
7083
|
|
|
6533
|
-
Note
|
|
6534
|
-
|
|
7084
|
+
Note:
|
|
7085
|
+
This is different than the longest common string algorithm, since
|
|
7086
|
+
matching characters in the two strings do not need to be contiguous.
|
|
6535
7087
|
|
|
6536
|
-
|
|
6537
|
-
|
|
7088
|
+
For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings
|
|
7089
|
+
from left to right, the longest common set of characters is composed of the first "f" and then the "o".
|
|
6538
7090
|
|
|
6539
|
-
See https://valkey.io/commands/lcs for more details.
|
|
7091
|
+
See [valkey.io](https://valkey.io/commands/lcs) for more details.
|
|
6540
7092
|
|
|
6541
7093
|
Args:
|
|
6542
7094
|
key1 (TEncodable): The key that stores the first string.
|
|
6543
7095
|
key2 (TEncodable): The key that stores the second string.
|
|
6544
7096
|
|
|
6545
7097
|
Returns:
|
|
6546
|
-
A Bytes String containing the longest common subsequence between the 2 strings.
|
|
7098
|
+
bytes: A Bytes String containing the longest common subsequence between the 2 strings.
|
|
7099
|
+
|
|
6547
7100
|
An empty String is returned if the keys do not exist or have no common subsequences.
|
|
6548
7101
|
|
|
6549
7102
|
Examples:
|
|
@@ -6569,13 +7122,14 @@ class CoreCommands(Protocol):
|
|
|
6569
7122
|
"""
|
|
6570
7123
|
Returns the length of the longest common subsequence between strings stored at key1 and key2.
|
|
6571
7124
|
|
|
6572
|
-
Note
|
|
6573
|
-
|
|
7125
|
+
Note:
|
|
7126
|
+
This is different than the longest common string algorithm, since
|
|
7127
|
+
matching characters in the two strings do not need to be contiguous.
|
|
6574
7128
|
|
|
6575
|
-
|
|
6576
|
-
|
|
7129
|
+
For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings
|
|
7130
|
+
from left to right, the longest common set of characters is composed of the first "f" and then the "o".
|
|
6577
7131
|
|
|
6578
|
-
See https://valkey.io/commands/lcs for more details.
|
|
7132
|
+
See [valkey.io](https://valkey.io/commands/lcs) for more details.
|
|
6579
7133
|
|
|
6580
7134
|
Args:
|
|
6581
7135
|
key1 (TEncodable): The key that stores the first string value.
|
|
@@ -6609,13 +7163,14 @@ class CoreCommands(Protocol):
|
|
|
6609
7163
|
"""
|
|
6610
7164
|
Returns the indices and length of the longest common subsequence between strings stored at key1 and key2.
|
|
6611
7165
|
|
|
6612
|
-
Note
|
|
6613
|
-
|
|
7166
|
+
Note:
|
|
7167
|
+
This is different than the longest common string algorithm, since
|
|
7168
|
+
matching characters in the two strings do not need to be contiguous.
|
|
6614
7169
|
|
|
6615
|
-
|
|
6616
|
-
|
|
7170
|
+
For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings
|
|
7171
|
+
from left to right, the longest common set of characters is composed of the first "f" and then the "o".
|
|
6617
7172
|
|
|
6618
|
-
See https://valkey.io/commands/lcs for more details.
|
|
7173
|
+
See [valkey.io](https://valkey.io/commands/lcs) for more details.
|
|
6619
7174
|
|
|
6620
7175
|
Args:
|
|
6621
7176
|
key1 (TEncodable): The key that stores the first string value.
|
|
@@ -6627,6 +7182,7 @@ class CoreCommands(Protocol):
|
|
|
6627
7182
|
A Mapping containing the indices of the longest common subsequence between the
|
|
6628
7183
|
2 strings and the length of the longest common subsequence. The resulting map contains two
|
|
6629
7184
|
keys, "matches" and "len":
|
|
7185
|
+
|
|
6630
7186
|
- "len" is mapped to the length of the longest common subsequence between the 2 strings.
|
|
6631
7187
|
- "matches" is mapped to a three dimensional int array that stores pairs of indices that
|
|
6632
7188
|
represent the location of the common subsequences in the strings held by key1 and key2,
|
|
@@ -6704,7 +7260,7 @@ class CoreCommands(Protocol):
|
|
|
6704
7260
|
Returns the index or indexes of element(s) matching `element` in the `key` list. If no match is found,
|
|
6705
7261
|
None is returned.
|
|
6706
7262
|
|
|
6707
|
-
See https://valkey.io/commands/lpos for more details.
|
|
7263
|
+
See [valkey.io](https://valkey.io/commands/lpos) for more details.
|
|
6708
7264
|
|
|
6709
7265
|
Args:
|
|
6710
7266
|
key (TEncodable): The name of the list.
|
|
@@ -6712,11 +7268,13 @@ class CoreCommands(Protocol):
|
|
|
6712
7268
|
rank (Optional[int]): The rank of the match to return.
|
|
6713
7269
|
count (Optional[int]): The number of matches wanted. A `count` of 0 returns all the matches.
|
|
6714
7270
|
max_len (Optional[int]): The maximum number of comparisons to make between the element and the items
|
|
6715
|
-
|
|
7271
|
+
in the list. A `max_len` of 0 means unlimited amount of comparisons.
|
|
6716
7272
|
|
|
6717
7273
|
Returns:
|
|
6718
|
-
Union[int, List[int], None]: The index of the first occurrence of `element
|
|
6719
|
-
|
|
7274
|
+
Union[int, List[int], None]: The index of the first occurrence of `element`.
|
|
7275
|
+
|
|
7276
|
+
`None` if `element` is not in the list.
|
|
7277
|
+
|
|
6720
7278
|
With the `count` option, a list of indices of matching elements will be returned.
|
|
6721
7279
|
|
|
6722
7280
|
Examples:
|
|
@@ -6757,15 +7315,16 @@ class CoreCommands(Protocol):
|
|
|
6757
7315
|
Lists the currently active channels.
|
|
6758
7316
|
The command is routed to all nodes, and aggregates the response to a single array.
|
|
6759
7317
|
|
|
6760
|
-
See https://valkey.io/commands/pubsub-channels for more details.
|
|
7318
|
+
See [valkey.io](https://valkey.io/commands/pubsub-channels) for more details.
|
|
6761
7319
|
|
|
6762
7320
|
Args:
|
|
6763
7321
|
pattern (Optional[TEncodable]): A glob-style pattern to match active channels.
|
|
6764
|
-
|
|
7322
|
+
If not provided, all active channels are returned.
|
|
6765
7323
|
|
|
6766
7324
|
Returns:
|
|
6767
7325
|
List[bytes]: A list of currently active channels matching the given pattern.
|
|
6768
|
-
|
|
7326
|
+
|
|
7327
|
+
If no pattern is specified, all active channels are returned.
|
|
6769
7328
|
|
|
6770
7329
|
Examples:
|
|
6771
7330
|
>>> await client.pubsub_channels()
|
|
@@ -6786,11 +7345,13 @@ class CoreCommands(Protocol):
|
|
|
6786
7345
|
"""
|
|
6787
7346
|
Returns the number of unique patterns that are subscribed to by clients.
|
|
6788
7347
|
|
|
6789
|
-
Note:
|
|
6790
|
-
|
|
6791
|
-
|
|
7348
|
+
Note:
|
|
7349
|
+
This is the total number of unique patterns all the clients are subscribed to,
|
|
7350
|
+
not the count of clients subscribed to patterns.
|
|
7351
|
+
|
|
7352
|
+
The command is routed to all nodes, and aggregates the response the sum of all pattern subscriptions.
|
|
6792
7353
|
|
|
6793
|
-
See https://valkey.io/commands/pubsub-numpat for more details.
|
|
7354
|
+
See [valkey.io](https://valkey.io/commands/pubsub-numpat) for more details.
|
|
6794
7355
|
|
|
6795
7356
|
Returns:
|
|
6796
7357
|
int: The number of unique patterns.
|
|
@@ -6807,14 +7368,17 @@ class CoreCommands(Protocol):
|
|
|
6807
7368
|
"""
|
|
6808
7369
|
Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
|
|
6809
7370
|
|
|
6810
|
-
Note
|
|
6811
|
-
|
|
7371
|
+
Note:
|
|
7372
|
+
It is valid to call this command without channels. In this case, it will just return an empty map.
|
|
7373
|
+
|
|
7374
|
+
The command is routed to all nodes, and aggregates the response to a single map of the channels and their number
|
|
7375
|
+
of subscriptions.
|
|
6812
7376
|
|
|
6813
|
-
See https://valkey.io/commands/pubsub-numsub for more details.
|
|
7377
|
+
See [valkey.io](https://valkey.io/commands/pubsub-numsub) for more details.
|
|
6814
7378
|
|
|
6815
7379
|
Args:
|
|
6816
7380
|
channels (Optional[List[TEncodable]]): The list of channels to query for the number of subscribers.
|
|
6817
|
-
|
|
7381
|
+
If not provided, returns an empty map.
|
|
6818
7382
|
|
|
6819
7383
|
Returns:
|
|
6820
7384
|
Mapping[bytes, int]: A map where keys are the channel names and values are the number of subscribers.
|
|
@@ -6844,19 +7408,22 @@ class CoreCommands(Protocol):
|
|
|
6844
7408
|
) -> List[Optional[bytes]]:
|
|
6845
7409
|
"""
|
|
6846
7410
|
Sorts the elements in the list, set, or sorted set at `key` and returns the result.
|
|
6847
|
-
The `sort` command can be used to sort elements based on different criteria and apply transformations on sorted
|
|
7411
|
+
The `sort` command can be used to sort elements based on different criteria and apply transformations on sorted
|
|
7412
|
+
elements.
|
|
6848
7413
|
This command is routed to primary nodes only.
|
|
6849
7414
|
To store the result into a new key, see `sort_store`.
|
|
6850
7415
|
|
|
6851
|
-
Note:
|
|
7416
|
+
Note:
|
|
7417
|
+
When in cluster mode, `key`, and any patterns specified in `by_pattern` or `get_patterns`
|
|
6852
7418
|
must map to the same hash slot. The use of `by_pattern` and `get_patterns` in cluster mode is supported
|
|
6853
7419
|
only since Valkey version 8.0.
|
|
6854
7420
|
|
|
6855
|
-
See https://valkey.io/commands/sort for more details.
|
|
7421
|
+
See [valkey.io](https://valkey.io/commands/sort) for more details.
|
|
6856
7422
|
|
|
6857
7423
|
Args:
|
|
6858
7424
|
key (TEncodable): The key of the list, set, or sorted set to be sorted.
|
|
6859
|
-
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the key
|
|
7425
|
+
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the key
|
|
7426
|
+
themselves.
|
|
6860
7427
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6861
7428
|
from the key replaces the asterisk to create the key name. For example, if `key` contains IDs of objects,
|
|
6862
7429
|
`by_pattern` can be used to sort these IDs based on an attribute of the objects, like their weights or
|
|
@@ -6865,8 +7432,10 @@ class CoreCommands(Protocol):
|
|
|
6865
7432
|
keys `weight_<element>`.
|
|
6866
7433
|
If not provided, elements are sorted by their value.
|
|
6867
7434
|
Supported in cluster mode since Valkey version 8.0.
|
|
6868
|
-
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
6869
|
-
|
|
7435
|
+
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
7436
|
+
more information.
|
|
7437
|
+
get_patterns (Optional[List[TEncodable]]): A pattern used to retrieve external keys' values, instead of the
|
|
7438
|
+
elements at `key`.
|
|
6870
7439
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6871
7440
|
from `key` replaces the asterisk to create the key name. This allows the sorted elements to be
|
|
6872
7441
|
transformed based on the related keys values. For example, if `key` contains IDs of users, `get_pattern`
|
|
@@ -6878,8 +7447,10 @@ class CoreCommands(Protocol):
|
|
|
6878
7447
|
Supported in cluster mode since Valkey version 8.0.
|
|
6879
7448
|
order (Optional[OrderBy]): Specifies the order to sort the elements.
|
|
6880
7449
|
Can be `OrderBy.ASC` (ascending) or `OrderBy.DESC` (descending).
|
|
6881
|
-
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
6882
|
-
|
|
7450
|
+
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7451
|
+
numerically.
|
|
7452
|
+
Use this when the list, set, or sorted set contains string values that cannot be converted into double
|
|
7453
|
+
precision floating point
|
|
6883
7454
|
|
|
6884
7455
|
Returns:
|
|
6885
7456
|
List[Optional[bytes]]: Returns a list of sorted elements.
|
|
@@ -6914,18 +7485,21 @@ class CoreCommands(Protocol):
|
|
|
6914
7485
|
) -> List[Optional[bytes]]:
|
|
6915
7486
|
"""
|
|
6916
7487
|
Sorts the elements in the list, set, or sorted set at `key` and returns the result.
|
|
6917
|
-
The `sort_ro` command can be used to sort elements based on different criteria and apply transformations on
|
|
7488
|
+
The `sort_ro` command can be used to sort elements based on different criteria and apply transformations on
|
|
7489
|
+
sorted elements.
|
|
6918
7490
|
This command is routed depending on the client's `ReadFrom` strategy.
|
|
6919
7491
|
|
|
6920
|
-
See https://valkey.io/commands/sort for more details.
|
|
7492
|
+
See [valkey.io](https://valkey.io/commands/sort) for more details.
|
|
6921
7493
|
|
|
6922
|
-
Note:
|
|
7494
|
+
Note:
|
|
7495
|
+
When in cluster mode, `key`, and any patterns specified in `by_pattern` or `get_patterns`
|
|
6923
7496
|
must map to the same hash slot. The use of `by_pattern` and `get_patterns` in cluster mode is supported
|
|
6924
7497
|
only since Valkey version 8.0.
|
|
6925
7498
|
|
|
6926
7499
|
Args:
|
|
6927
7500
|
key (TEncodable): The key of the list, set, or sorted set to be sorted.
|
|
6928
|
-
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the
|
|
7501
|
+
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the
|
|
7502
|
+
key themselves.
|
|
6929
7503
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6930
7504
|
from the key replaces the asterisk to create the key name. For example, if `key` contains IDs of objects,
|
|
6931
7505
|
`by_pattern` can be used to sort these IDs based on an attribute of the objects, like their weights or
|
|
@@ -6934,8 +7508,10 @@ class CoreCommands(Protocol):
|
|
|
6934
7508
|
keys `weight_<element>`.
|
|
6935
7509
|
If not provided, elements are sorted by their value.
|
|
6936
7510
|
Supported in cluster mode since Valkey version 8.0.
|
|
6937
|
-
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
6938
|
-
|
|
7511
|
+
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
7512
|
+
more information.
|
|
7513
|
+
get_patterns (Optional[List[TEncodable]]): A pattern used to retrieve external keys' values, instead of the
|
|
7514
|
+
elements at `key`.
|
|
6939
7515
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6940
7516
|
from `key` replaces the asterisk to create the key name. This allows the sorted elements to be
|
|
6941
7517
|
transformed based on the related keys values. For example, if `key` contains IDs of users, `get_pattern`
|
|
@@ -6947,8 +7523,10 @@ class CoreCommands(Protocol):
|
|
|
6947
7523
|
Supported in cluster mode since Valkey version 8.0.
|
|
6948
7524
|
order (Optional[OrderBy]): Specifies the order to sort the elements.
|
|
6949
7525
|
Can be `OrderBy.ASC` (ascending) or `OrderBy.DESC` (descending).
|
|
6950
|
-
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
6951
|
-
|
|
7526
|
+
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7527
|
+
numerically.
|
|
7528
|
+
Use this when the list, set, or sorted set contains string values that cannot be converted into double
|
|
7529
|
+
precision floating point
|
|
6952
7530
|
|
|
6953
7531
|
Returns:
|
|
6954
7532
|
List[Optional[bytes]]: Returns a list of sorted elements.
|
|
@@ -6986,19 +7564,22 @@ class CoreCommands(Protocol):
|
|
|
6986
7564
|
) -> int:
|
|
6987
7565
|
"""
|
|
6988
7566
|
Sorts the elements in the list, set, or sorted set at `key` and stores the result in `store`.
|
|
6989
|
-
The `sort` command can be used to sort elements based on different criteria, apply transformations on sorted elements,
|
|
7567
|
+
The `sort` command can be used to sort elements based on different criteria, apply transformations on sorted elements,
|
|
7568
|
+
and store the result in a new key.
|
|
6990
7569
|
To get the sort result without storing it into a key, see `sort`.
|
|
6991
7570
|
|
|
6992
|
-
See https://valkey.io/commands/sort for more details.
|
|
7571
|
+
See [valkey.io](https://valkey.io/commands/sort) for more details.
|
|
6993
7572
|
|
|
6994
|
-
Note:
|
|
7573
|
+
Note:
|
|
7574
|
+
When in cluster mode, `key`, `destination`, and any patterns specified in `by_pattern` or `get_patterns`
|
|
6995
7575
|
must map to the same hash slot. The use of `by_pattern` and `get_patterns` in cluster mode is supported
|
|
6996
7576
|
only since Valkey version 8.0.
|
|
6997
7577
|
|
|
6998
7578
|
Args:
|
|
6999
7579
|
key (TEncodable): The key of the list, set, or sorted set to be sorted.
|
|
7000
7580
|
destination (TEncodable): The key where the sorted result will be stored.
|
|
7001
|
-
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the key
|
|
7581
|
+
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the key
|
|
7582
|
+
themselves.
|
|
7002
7583
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
7003
7584
|
from the key replaces the asterisk to create the key name. For example, if `key` contains IDs of objects,
|
|
7004
7585
|
`by_pattern` can be used to sort these IDs based on an attribute of the objects, like their weights or
|
|
@@ -7007,8 +7588,10 @@ class CoreCommands(Protocol):
|
|
|
7007
7588
|
keys `weight_<element>`.
|
|
7008
7589
|
If not provided, elements are sorted by their value.
|
|
7009
7590
|
Supported in cluster mode since Valkey version 8.0.
|
|
7010
|
-
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
7011
|
-
|
|
7591
|
+
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
7592
|
+
more information.
|
|
7593
|
+
get_patterns (Optional[List[TEncodable]]): A pattern used to retrieve external keys' values, instead of the
|
|
7594
|
+
elements at `key`.
|
|
7012
7595
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
7013
7596
|
from `key` replaces the asterisk to create the key name. This allows the sorted elements to be
|
|
7014
7597
|
transformed based on the related keys values. For example, if `key` contains IDs of users, `get_pattern`
|
|
@@ -7020,8 +7603,10 @@ class CoreCommands(Protocol):
|
|
|
7020
7603
|
Supported in cluster mode since Valkey version 8.0.
|
|
7021
7604
|
order (Optional[OrderBy]): Specifies the order to sort the elements.
|
|
7022
7605
|
Can be `OrderBy.ASC` (ascending) or `OrderBy.DESC` (descending).
|
|
7023
|
-
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7024
|
-
|
|
7606
|
+
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7607
|
+
numerically.
|
|
7608
|
+
Use this when the list, set, or sorted set contains string values that cannot be converted into double
|
|
7609
|
+
precision floating point
|
|
7025
7610
|
|
|
7026
7611
|
Returns:
|
|
7027
7612
|
int: The number of elements in the sorted key stored at `store`.
|