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