valkey-glide 1.3.5rc5__cp312-cp312-macosx_11_0_arm64.whl → 2.0.0__cp312-cp312-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 +32 -8
- glide/async_commands/{transaction.py → batch.py} +1420 -992
- glide/async_commands/batch_options.py +261 -0
- glide/async_commands/bitmap.py +94 -85
- glide/async_commands/cluster_commands.py +293 -126
- glide/async_commands/command_args.py +7 -6
- glide/async_commands/core.py +1313 -721
- 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 +202 -95
- glide/async_commands/stream.py +94 -87
- glide/config.py +253 -112
- glide/constants.py +8 -4
- glide/glide.cpython-312-darwin.so +0 -0
- glide/glide.pyi +25 -0
- glide/glide_client.py +305 -94
- glide/logger.py +31 -19
- glide/opentelemetry.py +181 -0
- glide/protobuf/command_request_pb2.py +15 -15
- glide/protobuf/command_request_pb2.pyi +75 -46
- glide/protobuf/connection_request_pb2.py +12 -12
- glide/protobuf/connection_request_pb2.pyi +36 -29
- glide/protobuf/response_pb2.py +6 -6
- glide/protobuf/response_pb2.pyi +14 -9
- glide/protobuf_codec.py +7 -6
- glide/routes.py +41 -8
- {valkey_glide-1.3.5rc5.dist-info → valkey_glide-2.0.0.dist-info}/METADATA +38 -14
- valkey_glide-2.0.0.dist-info/RECORD +39 -0
- valkey_glide-1.3.5rc5.dist-info/RECORD +0 -37
- {valkey_glide-1.3.5rc5.dist-info → valkey_glide-2.0.0.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 list is emptied
|
|
2540
|
+
and the key is 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)
|
|
@@ -2358,20 +2555,24 @@ class CoreCommands(Protocol):
|
|
|
2358
2555
|
async def lrem(self, key: TEncodable, count: int, element: TEncodable) -> int:
|
|
2359
2556
|
"""
|
|
2360
2557
|
Removes the first `count` occurrences of elements equal to `element` from the list stored at `key`.
|
|
2361
|
-
If `count` is positive, it removes elements equal to `element` moving from head to tail.
|
|
2362
|
-
If `count` is negative, it removes elements equal to `element` moving from tail to head.
|
|
2363
|
-
If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
|
|
2364
2558
|
equal to `element`.
|
|
2365
|
-
|
|
2559
|
+
|
|
2560
|
+
See [valkey.io](https://valkey.io/commands/lrem/) for more details.
|
|
2366
2561
|
|
|
2367
2562
|
Args:
|
|
2368
2563
|
key (TEncodable): The key of the list.
|
|
2369
2564
|
count (int): The count of occurrences of elements equal to `element` to remove.
|
|
2565
|
+
|
|
2566
|
+
- If `count` is positive, it removes elements equal to `element` moving from head to tail.
|
|
2567
|
+
- If `count` is negative, it removes elements equal to `element` moving from tail to head.
|
|
2568
|
+
- If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
|
|
2569
|
+
|
|
2370
2570
|
element (TEncodable): The element to remove from the list.
|
|
2371
2571
|
|
|
2372
2572
|
Returns:
|
|
2373
2573
|
int: The number of removed elements.
|
|
2374
|
-
|
|
2574
|
+
|
|
2575
|
+
If `key` does not exist, 0 is returned.
|
|
2375
2576
|
|
|
2376
2577
|
Examples:
|
|
2377
2578
|
>>> await client.lrem("my_list", 2, "value")
|
|
@@ -2385,14 +2586,16 @@ class CoreCommands(Protocol):
|
|
|
2385
2586
|
async def llen(self, key: TEncodable) -> int:
|
|
2386
2587
|
"""
|
|
2387
2588
|
Get the length of the list stored at `key`.
|
|
2388
|
-
|
|
2589
|
+
|
|
2590
|
+
See [valkey.io](https://valkey.io/commands/llen/) for details.
|
|
2389
2591
|
|
|
2390
2592
|
Args:
|
|
2391
2593
|
key (TEncodable): The key of the list.
|
|
2392
2594
|
|
|
2393
2595
|
Returns:
|
|
2394
2596
|
int: The length of the list at the specified key.
|
|
2395
|
-
|
|
2597
|
+
|
|
2598
|
+
If `key` does not exist, it is interpreted as an empty list and 0 is returned.
|
|
2396
2599
|
|
|
2397
2600
|
Examples:
|
|
2398
2601
|
>>> await client.llen("my_list")
|
|
@@ -2403,7 +2606,8 @@ class CoreCommands(Protocol):
|
|
|
2403
2606
|
async def exists(self, keys: List[TEncodable]) -> int:
|
|
2404
2607
|
"""
|
|
2405
2608
|
Returns the number of keys in `keys` that exist in the database.
|
|
2406
|
-
|
|
2609
|
+
|
|
2610
|
+
See [valkey.io](https://valkey.io/commands/exists/) for more details.
|
|
2407
2611
|
|
|
2408
2612
|
Note:
|
|
2409
2613
|
In cluster mode, if keys in `keys` map to different hash slots,
|
|
@@ -2419,7 +2623,7 @@ class CoreCommands(Protocol):
|
|
|
2419
2623
|
|
|
2420
2624
|
Returns:
|
|
2421
2625
|
int: The number of keys that exist. If the same existing key is mentioned in `keys` multiple times,
|
|
2422
|
-
|
|
2626
|
+
it will be counted multiple times.
|
|
2423
2627
|
|
|
2424
2628
|
Examples:
|
|
2425
2629
|
>>> await client.exists(["key1", "key2", "key3"])
|
|
@@ -2433,7 +2637,8 @@ class CoreCommands(Protocol):
|
|
|
2433
2637
|
A key is ignored if it does not exist.
|
|
2434
2638
|
This command, similar to DEL, removes specified keys and ignores non-existent ones.
|
|
2435
2639
|
However, this command does not block the server, while [DEL](https://valkey.io/commands/del) does.
|
|
2436
|
-
|
|
2640
|
+
|
|
2641
|
+
See [valkey.io](https://valkey.io/commands/unlink/) for more details.
|
|
2437
2642
|
|
|
2438
2643
|
Note:
|
|
2439
2644
|
In cluster mode, if keys in `key_value_map` map to different hash slots,
|
|
@@ -2467,7 +2672,8 @@ class CoreCommands(Protocol):
|
|
|
2467
2672
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2468
2673
|
If `seconds` is a non-positive number, the key will be deleted rather than expired.
|
|
2469
2674
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2470
|
-
|
|
2675
|
+
|
|
2676
|
+
See [valkey.io](https://valkey.io/commands/expire/) for more details.
|
|
2471
2677
|
|
|
2472
2678
|
Args:
|
|
2473
2679
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2475,8 +2681,10 @@ class CoreCommands(Protocol):
|
|
|
2475
2681
|
option (ExpireOptions, optional): The expire option.
|
|
2476
2682
|
|
|
2477
2683
|
Returns:
|
|
2478
|
-
bool:
|
|
2479
|
-
|
|
2684
|
+
bool: `True` if the timeout was set.
|
|
2685
|
+
|
|
2686
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2687
|
+
operation is skipped due to the provided arguments).
|
|
2480
2688
|
|
|
2481
2689
|
Examples:
|
|
2482
2690
|
>>> await client.expire("my_key", 60)
|
|
@@ -2500,7 +2708,8 @@ class CoreCommands(Protocol):
|
|
|
2500
2708
|
deleted.
|
|
2501
2709
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2502
2710
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2503
|
-
|
|
2711
|
+
|
|
2712
|
+
See [valkey.io](https://valkey.io/commands/expireat/) for more details.
|
|
2504
2713
|
|
|
2505
2714
|
Args:
|
|
2506
2715
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2508,8 +2717,10 @@ class CoreCommands(Protocol):
|
|
|
2508
2717
|
option (Optional[ExpireOptions]): The expire option.
|
|
2509
2718
|
|
|
2510
2719
|
Returns:
|
|
2511
|
-
bool:
|
|
2512
|
-
|
|
2720
|
+
bool: `True` if the timeout was set.
|
|
2721
|
+
|
|
2722
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2723
|
+
operation is skipped due to the provided arguments).
|
|
2513
2724
|
|
|
2514
2725
|
Examples:
|
|
2515
2726
|
>>> await client.expireAt("my_key", 1672531200, ExpireOptions.HasNoExpiry)
|
|
@@ -2533,7 +2744,8 @@ class CoreCommands(Protocol):
|
|
|
2533
2744
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2534
2745
|
If `milliseconds` is a non-positive number, the key will be deleted rather than expired.
|
|
2535
2746
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2536
|
-
|
|
2747
|
+
|
|
2748
|
+
See [valkey.io](https://valkey.io/commands/pexpire/) for more details.
|
|
2537
2749
|
|
|
2538
2750
|
Args:
|
|
2539
2751
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2541,8 +2753,10 @@ class CoreCommands(Protocol):
|
|
|
2541
2753
|
option (Optional[ExpireOptions]): The expire option.
|
|
2542
2754
|
|
|
2543
2755
|
Returns:
|
|
2544
|
-
bool:
|
|
2545
|
-
|
|
2756
|
+
bool: `True` if the timeout was set
|
|
2757
|
+
|
|
2758
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2759
|
+
operation is skipped due to the provided arguments).
|
|
2546
2760
|
|
|
2547
2761
|
Examples:
|
|
2548
2762
|
>>> await client.pexpire("my_key", 60000, ExpireOptions.HasNoExpiry)
|
|
@@ -2568,7 +2782,8 @@ class CoreCommands(Protocol):
|
|
|
2568
2782
|
deleted.
|
|
2569
2783
|
If `key` already has an existing expire set, the time to live is updated to the new value.
|
|
2570
2784
|
The timeout will only be cleared by commands that delete or overwrite the contents of `key`.
|
|
2571
|
-
|
|
2785
|
+
|
|
2786
|
+
See [valkey.io](https://valkey.io/commands/pexpireat/) for more details.
|
|
2572
2787
|
|
|
2573
2788
|
Args:
|
|
2574
2789
|
key (TEncodable): The key to set a timeout on.
|
|
@@ -2576,8 +2791,10 @@ class CoreCommands(Protocol):
|
|
|
2576
2791
|
option (Optional[ExpireOptions]): The expire option.
|
|
2577
2792
|
|
|
2578
2793
|
Returns:
|
|
2579
|
-
bool:
|
|
2580
|
-
|
|
2794
|
+
bool: `True` if the timeout was set.
|
|
2795
|
+
|
|
2796
|
+
`False` if the timeout was not set (e.g., the key doesn't exist or the
|
|
2797
|
+
operation is skipped due to the provided arguments).
|
|
2581
2798
|
|
|
2582
2799
|
Examples:
|
|
2583
2800
|
>>> await client.pexpireAt("my_key", 1672531200000, ExpireOptions.HasNoExpiry)
|
|
@@ -2596,13 +2813,17 @@ class CoreCommands(Protocol):
|
|
|
2596
2813
|
the given `key` will expire, in seconds.
|
|
2597
2814
|
To get the expiration with millisecond precision, use `pexpiretime`.
|
|
2598
2815
|
|
|
2599
|
-
See https://valkey.io/commands/expiretime/ for details.
|
|
2816
|
+
See [valkey.io](https://valkey.io/commands/expiretime/) for details.
|
|
2600
2817
|
|
|
2601
2818
|
Args:
|
|
2602
2819
|
key (TEncodable): The `key` to determine the expiration value of.
|
|
2603
2820
|
|
|
2604
2821
|
Returns:
|
|
2605
|
-
int: The expiration Unix timestamp in seconds
|
|
2822
|
+
int: The expiration Unix timestamp in seconds.
|
|
2823
|
+
|
|
2824
|
+
-2 if `key` does not exist.
|
|
2825
|
+
|
|
2826
|
+
-1 if `key` exists but has no associated expire.
|
|
2606
2827
|
|
|
2607
2828
|
Examples:
|
|
2608
2829
|
>>> await client.expiretime("my_key")
|
|
@@ -2623,13 +2844,17 @@ class CoreCommands(Protocol):
|
|
|
2623
2844
|
Returns the absolute Unix timestamp (since January 1, 1970) at which
|
|
2624
2845
|
the given `key` will expire, in milliseconds.
|
|
2625
2846
|
|
|
2626
|
-
See https://valkey.io/commands/pexpiretime/ for details.
|
|
2847
|
+
See [valkey.io](https://valkey.io/commands/pexpiretime/) for details.
|
|
2627
2848
|
|
|
2628
2849
|
Args:
|
|
2629
2850
|
key (TEncodable): The `key` to determine the expiration value of.
|
|
2630
2851
|
|
|
2631
2852
|
Returns:
|
|
2632
|
-
int: The expiration Unix timestamp in milliseconds
|
|
2853
|
+
int: The expiration Unix timestamp in milliseconds.
|
|
2854
|
+
|
|
2855
|
+
-2 if `key` does not exist.
|
|
2856
|
+
|
|
2857
|
+
-1 if `key` exists but has no associated expiration.
|
|
2633
2858
|
|
|
2634
2859
|
Examples:
|
|
2635
2860
|
>>> await client.pexpiretime("my_key")
|
|
@@ -2648,13 +2873,18 @@ class CoreCommands(Protocol):
|
|
|
2648
2873
|
async def ttl(self, key: TEncodable) -> int:
|
|
2649
2874
|
"""
|
|
2650
2875
|
Returns the remaining time to live of `key` that has a timeout.
|
|
2651
|
-
|
|
2876
|
+
|
|
2877
|
+
See [valkey.io](https://valkey.io/commands/ttl/) for more details.
|
|
2652
2878
|
|
|
2653
2879
|
Args:
|
|
2654
2880
|
key (TEncodable): The key to return its timeout.
|
|
2655
2881
|
|
|
2656
2882
|
Returns:
|
|
2657
|
-
int: TTL in seconds
|
|
2883
|
+
int: TTL in seconds.
|
|
2884
|
+
|
|
2885
|
+
-2 if `key` does not exist.
|
|
2886
|
+
|
|
2887
|
+
-1 if `key` exists but has no associated expire.
|
|
2658
2888
|
|
|
2659
2889
|
Examples:
|
|
2660
2890
|
>>> await client.ttl("my_key")
|
|
@@ -2672,13 +2902,18 @@ class CoreCommands(Protocol):
|
|
|
2672
2902
|
) -> int:
|
|
2673
2903
|
"""
|
|
2674
2904
|
Returns the remaining time to live of `key` that has a timeout, in milliseconds.
|
|
2675
|
-
|
|
2905
|
+
|
|
2906
|
+
See [valkey.io](https://valkey.io/commands/pttl) for more details.
|
|
2676
2907
|
|
|
2677
2908
|
Args:
|
|
2678
2909
|
key (TEncodable): The key to return its timeout.
|
|
2679
2910
|
|
|
2680
2911
|
Returns:
|
|
2681
|
-
int: TTL in milliseconds.
|
|
2912
|
+
int: TTL in milliseconds.
|
|
2913
|
+
|
|
2914
|
+
-2 if `key` does not exist.
|
|
2915
|
+
|
|
2916
|
+
-1 if `key` exists but has no associated expire.
|
|
2682
2917
|
|
|
2683
2918
|
Examples:
|
|
2684
2919
|
>>> await client.pttl("my_key")
|
|
@@ -2699,13 +2934,15 @@ class CoreCommands(Protocol):
|
|
|
2699
2934
|
Remove the existing timeout on `key`, turning the key from volatile (a key with an expire set) to
|
|
2700
2935
|
persistent (a key that will never expire as no timeout is associated).
|
|
2701
2936
|
|
|
2702
|
-
See https://valkey.io/commands/persist/ for more details.
|
|
2937
|
+
See [valkey.io](https://valkey.io/commands/persist/) for more details.
|
|
2703
2938
|
|
|
2704
2939
|
Args:
|
|
2705
2940
|
key (TEncodable): The key to remove the existing timeout on.
|
|
2706
2941
|
|
|
2707
2942
|
Returns:
|
|
2708
|
-
bool: False if `key` does not exist or does not have an associated timeout
|
|
2943
|
+
bool: `False` if `key` does not exist or does not have an associated timeout.
|
|
2944
|
+
|
|
2945
|
+
`True` if the timeout has been removed.
|
|
2709
2946
|
|
|
2710
2947
|
Examples:
|
|
2711
2948
|
>>> await client.persist("my_key")
|
|
@@ -2720,13 +2957,14 @@ class CoreCommands(Protocol):
|
|
|
2720
2957
|
"""
|
|
2721
2958
|
Returns the bytes string representation of the type of the value stored at `key`.
|
|
2722
2959
|
|
|
2723
|
-
See https://valkey.io/commands/type/ for more details.
|
|
2960
|
+
See [valkey.io](https://valkey.io/commands/type/) for more details.
|
|
2724
2961
|
|
|
2725
2962
|
Args:
|
|
2726
2963
|
key (TEncodable): The key to check its data type.
|
|
2727
2964
|
|
|
2728
2965
|
Returns:
|
|
2729
2966
|
bytes: If the key exists, the type of the stored value is returned.
|
|
2967
|
+
|
|
2730
2968
|
Otherwise, a b"none" bytes string is returned.
|
|
2731
2969
|
|
|
2732
2970
|
Examples:
|
|
@@ -2748,20 +2986,28 @@ class CoreCommands(Protocol):
|
|
|
2748
2986
|
"""
|
|
2749
2987
|
Adds an entry to the specified stream stored at `key`. If the `key` doesn't exist, the stream is created.
|
|
2750
2988
|
|
|
2751
|
-
See https://valkey.io/commands/xadd for more details.
|
|
2989
|
+
See [valkey.io](https://valkey.io/commands/xadd) for more details.
|
|
2752
2990
|
|
|
2753
2991
|
Args:
|
|
2754
2992
|
key (TEncodable): The key of the stream.
|
|
2755
2993
|
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.
|
|
2994
|
+
options (Optional[StreamAddOptions]): Additional options for adding entries to the stream. Default to None.
|
|
2995
|
+
See `StreamAddOptions`.
|
|
2757
2996
|
|
|
2758
2997
|
Returns:
|
|
2759
|
-
bytes: The id of the added entry
|
|
2998
|
+
bytes: The id of the added entry.
|
|
2999
|
+
|
|
3000
|
+
`None` if `options.make_stream` is set to False and no stream with the matching
|
|
3001
|
+
`key` exists.
|
|
2760
3002
|
|
|
2761
3003
|
Example:
|
|
2762
3004
|
>>> await client.xadd("mystream", [("field", "value"), ("field2", "value2")])
|
|
2763
3005
|
b"1615957011958-0" # Example stream entry ID.
|
|
2764
|
-
>>> await client.xadd(
|
|
3006
|
+
>>> await client.xadd(
|
|
3007
|
+
... "non_existing_stream",
|
|
3008
|
+
... [(field, "foo1"), (field2, "bar1")],
|
|
3009
|
+
... StreamAddOptions(id="0-1", make_stream=False)
|
|
3010
|
+
... )
|
|
2765
3011
|
None # The key doesn't exist, therefore, None is returned.
|
|
2766
3012
|
>>> await client.xadd("non_existing_stream", [(field, "foo1"), (field2, "bar1")], StreamAddOptions(id="0-1"))
|
|
2767
3013
|
b"0-1" # Returns the stream id.
|
|
@@ -2781,7 +3027,7 @@ class CoreCommands(Protocol):
|
|
|
2781
3027
|
"""
|
|
2782
3028
|
Removes the specified entries by id from a stream, and returns the number of entries deleted.
|
|
2783
3029
|
|
|
2784
|
-
See https://valkey.io/commands/xdel for more details.
|
|
3030
|
+
See [valkey.io](https://valkey.io/commands/xdel) for more details.
|
|
2785
3031
|
|
|
2786
3032
|
Args:
|
|
2787
3033
|
key (TEncodable): The key of the stream.
|
|
@@ -2789,7 +3035,7 @@ class CoreCommands(Protocol):
|
|
|
2789
3035
|
|
|
2790
3036
|
Returns:
|
|
2791
3037
|
int: The number of entries removed from the stream. This number may be less than the number of entries in
|
|
2792
|
-
|
|
3038
|
+
`ids`, if the specified `ids` don't exist in the stream.
|
|
2793
3039
|
|
|
2794
3040
|
Examples:
|
|
2795
3041
|
>>> await client.xdel("key", ["1538561698944-0", "1538561698944-1"])
|
|
@@ -2810,14 +3056,16 @@ class CoreCommands(Protocol):
|
|
|
2810
3056
|
"""
|
|
2811
3057
|
Trims the stream stored at `key` by evicting older entries.
|
|
2812
3058
|
|
|
2813
|
-
See https://valkey.io/commands/xtrim for more details.
|
|
3059
|
+
See [valkey.io](https://valkey.io/commands/xtrim) for more details.
|
|
2814
3060
|
|
|
2815
3061
|
Args:
|
|
2816
3062
|
key (TEncodable): The key of the stream.
|
|
2817
3063
|
options (StreamTrimOptions): Options detailing how to trim the stream. See `StreamTrimOptions`.
|
|
2818
3064
|
|
|
2819
3065
|
Returns:
|
|
2820
|
-
int: TThe number of entries deleted from the stream.
|
|
3066
|
+
int: TThe number of entries deleted from the stream.
|
|
3067
|
+
|
|
3068
|
+
If `key` doesn't exist, 0 is returned.
|
|
2821
3069
|
|
|
2822
3070
|
Example:
|
|
2823
3071
|
>>> await client.xadd("mystream", [("field", "value"), ("field2", "value2")], StreamAddOptions(id="0-1"))
|
|
@@ -2834,13 +3082,15 @@ class CoreCommands(Protocol):
|
|
|
2834
3082
|
"""
|
|
2835
3083
|
Returns the number of entries in the stream stored at `key`.
|
|
2836
3084
|
|
|
2837
|
-
See https://valkey.io/commands/xlen for more details.
|
|
3085
|
+
See [valkey.io](https://valkey.io/commands/xlen) for more details.
|
|
2838
3086
|
|
|
2839
3087
|
Args:
|
|
2840
3088
|
key (TEncodable): The key of the stream.
|
|
2841
3089
|
|
|
2842
3090
|
Returns:
|
|
2843
|
-
int: The number of entries in the stream.
|
|
3091
|
+
int: The number of entries in the stream.
|
|
3092
|
+
|
|
3093
|
+
If `key` does not exist, returns 0.
|
|
2844
3094
|
|
|
2845
3095
|
Examples:
|
|
2846
3096
|
>>> await client.xadd("mystream", [("field", "value")])
|
|
@@ -2863,25 +3113,30 @@ class CoreCommands(Protocol):
|
|
|
2863
3113
|
"""
|
|
2864
3114
|
Returns stream entries matching a given range of IDs.
|
|
2865
3115
|
|
|
2866
|
-
See https://valkey.io/commands/xrange for more details.
|
|
3116
|
+
See [valkey.io](https://valkey.io/commands/xrange) for more details.
|
|
2867
3117
|
|
|
2868
3118
|
Args:
|
|
2869
3119
|
key (TEncodable): The key of the stream.
|
|
2870
|
-
start (StreamRangeBound): The starting stream ID bound for the range.
|
|
2871
|
-
|
|
2872
|
-
- Use `
|
|
3120
|
+
start (StreamRangeBound): The starting stream entry ID bound for the range.
|
|
3121
|
+
|
|
3122
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3123
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
2873
3124
|
- Use `MinId` to start with the minimum available ID.
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
3125
|
+
|
|
3126
|
+
end (StreamRangeBound): The ending stream entry ID bound for the range.
|
|
3127
|
+
|
|
3128
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3129
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
2877
3130
|
- Use `MaxId` to end with the maximum available ID.
|
|
3131
|
+
|
|
2878
3132
|
count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
|
|
2879
3133
|
If `count` is not provided, all stream entries in the range will be returned.
|
|
2880
3134
|
|
|
2881
3135
|
Returns:
|
|
2882
|
-
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
|
|
2883
|
-
|
|
2884
|
-
|
|
3136
|
+
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream entry IDs to stream entry data, where entry data is a
|
|
3137
|
+
list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3138
|
+
|
|
3139
|
+
Returns None if the range arguments are not applicable. Or if count is non-positive.
|
|
2885
3140
|
|
|
2886
3141
|
Examples:
|
|
2887
3142
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="0-1"))
|
|
@@ -2912,25 +3167,30 @@ class CoreCommands(Protocol):
|
|
|
2912
3167
|
Returns stream entries matching a given range of IDs in reverse order. Equivalent to `XRANGE` but returns the
|
|
2913
3168
|
entries in reverse order.
|
|
2914
3169
|
|
|
2915
|
-
See https://valkey.io/commands/xrevrange for more details.
|
|
3170
|
+
See [valkey.io](https://valkey.io/commands/xrevrange) for more details.
|
|
2916
3171
|
|
|
2917
3172
|
Args:
|
|
2918
3173
|
key (TEncodable): The key of the stream.
|
|
2919
|
-
end (StreamRangeBound): The ending stream ID bound for the range.
|
|
2920
|
-
|
|
2921
|
-
- Use `
|
|
3174
|
+
end (StreamRangeBound): The ending stream entry ID bound for the range.
|
|
3175
|
+
|
|
3176
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3177
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
2922
3178
|
- Use `MaxId` to end with the maximum available ID.
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
3179
|
+
|
|
3180
|
+
start (StreamRangeBound): The starting stream entry ID bound for the range.
|
|
3181
|
+
|
|
3182
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3183
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
2926
3184
|
- Use `MinId` to start with the minimum available ID.
|
|
3185
|
+
|
|
2927
3186
|
count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
|
|
2928
3187
|
If `count` is not provided, all stream entries in the range will be returned.
|
|
2929
3188
|
|
|
2930
3189
|
Returns:
|
|
2931
|
-
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
|
|
2932
|
-
|
|
2933
|
-
|
|
3190
|
+
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream entry IDs to stream entry data, where entry data is a
|
|
3191
|
+
list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3192
|
+
|
|
3193
|
+
Returns None if the range arguments are not applicable. Or if count is non-positive.
|
|
2934
3194
|
|
|
2935
3195
|
Examples:
|
|
2936
3196
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="0-1"))
|
|
@@ -2958,7 +3218,7 @@ class CoreCommands(Protocol):
|
|
|
2958
3218
|
"""
|
|
2959
3219
|
Reads entries from the given streams.
|
|
2960
3220
|
|
|
2961
|
-
See https://valkey.io/commands/xread for more details.
|
|
3221
|
+
See [valkey.io](https://valkey.io/commands/xread) for more details.
|
|
2962
3222
|
|
|
2963
3223
|
Note:
|
|
2964
3224
|
When in cluster mode, all keys in `keys_and_ids` must map to the same hash slot.
|
|
@@ -2969,9 +3229,12 @@ class CoreCommands(Protocol):
|
|
|
2969
3229
|
|
|
2970
3230
|
Returns:
|
|
2971
3231
|
Optional[Mapping[bytes, Mapping[bytes, List[List[bytes]]]]]: A mapping of stream keys, to a mapping of stream IDs,
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3232
|
+
to a list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3233
|
+
|
|
3234
|
+
None will be returned under the following conditions:
|
|
3235
|
+
|
|
3236
|
+
- All key-ID pairs in `keys_and_ids` have either a non-existing key or a non-existing ID, or there are no
|
|
3237
|
+
entries after the given ID.
|
|
2975
3238
|
- The `BLOCK` option is specified and the timeout is hit.
|
|
2976
3239
|
|
|
2977
3240
|
Examples:
|
|
@@ -3007,13 +3270,13 @@ class CoreCommands(Protocol):
|
|
|
3007
3270
|
"""
|
|
3008
3271
|
Creates a new consumer group uniquely identified by `group_name` for the stream stored at `key`.
|
|
3009
3272
|
|
|
3010
|
-
See https://valkey.io/commands/xgroup-create for more details.
|
|
3273
|
+
See [valkey.io](https://valkey.io/commands/xgroup-create) for more details.
|
|
3011
3274
|
|
|
3012
3275
|
Args:
|
|
3013
3276
|
key (TEncodable): The key of the stream.
|
|
3014
3277
|
group_name (TEncodable): The newly created consumer group name.
|
|
3015
3278
|
group_id (TEncodable): The stream entry ID that specifies the last delivered entry in the stream from the new
|
|
3016
|
-
group
|
|
3279
|
+
group's perspective. The special ID "$" can be used to specify the last entry in the stream.
|
|
3017
3280
|
options (Optional[StreamGroupOptions]): Options for creating the stream group.
|
|
3018
3281
|
|
|
3019
3282
|
Returns:
|
|
@@ -3038,14 +3301,16 @@ class CoreCommands(Protocol):
|
|
|
3038
3301
|
"""
|
|
3039
3302
|
Destroys the consumer group `group_name` for the stream stored at `key`.
|
|
3040
3303
|
|
|
3041
|
-
See https://valkey.io/commands/xgroup-destroy for more details.
|
|
3304
|
+
See [valkey.io](https://valkey.io/commands/xgroup-destroy) for more details.
|
|
3042
3305
|
|
|
3043
3306
|
Args:
|
|
3044
3307
|
key (TEncodable): The key of the stream.
|
|
3045
3308
|
group_name (TEncodable): The consumer group name to delete.
|
|
3046
3309
|
|
|
3047
3310
|
Returns:
|
|
3048
|
-
bool: True if the consumer group was destroyed.
|
|
3311
|
+
bool: True if the consumer group was destroyed.
|
|
3312
|
+
|
|
3313
|
+
Otherwise, returns False.
|
|
3049
3314
|
|
|
3050
3315
|
Examples:
|
|
3051
3316
|
>>> await client.xgroup_destroy("mystream", "mygroup")
|
|
@@ -3065,7 +3330,7 @@ class CoreCommands(Protocol):
|
|
|
3065
3330
|
"""
|
|
3066
3331
|
Creates a consumer named `consumer_name` in the consumer group `group_name` for the stream stored at `key`.
|
|
3067
3332
|
|
|
3068
|
-
See https://valkey.io/commands/xgroup-createconsumer for more details.
|
|
3333
|
+
See [valkey.io](https://valkey.io/commands/xgroup-createconsumer) for more details.
|
|
3069
3334
|
|
|
3070
3335
|
Args:
|
|
3071
3336
|
key (TEncodable): The key of the stream.
|
|
@@ -3073,7 +3338,9 @@ class CoreCommands(Protocol):
|
|
|
3073
3338
|
consumer_name (TEncodable): The newly created consumer.
|
|
3074
3339
|
|
|
3075
3340
|
Returns:
|
|
3076
|
-
bool: True if the consumer is created.
|
|
3341
|
+
bool: True if the consumer is created.
|
|
3342
|
+
|
|
3343
|
+
Otherwise, returns False.
|
|
3077
3344
|
|
|
3078
3345
|
Examples:
|
|
3079
3346
|
>>> await client.xgroup_create_consumer("mystream", "mygroup", "myconsumer")
|
|
@@ -3095,7 +3362,7 @@ class CoreCommands(Protocol):
|
|
|
3095
3362
|
"""
|
|
3096
3363
|
Deletes a consumer named `consumer_name` in the consumer group `group_name` for the stream stored at `key`.
|
|
3097
3364
|
|
|
3098
|
-
See https://valkey.io/commands/xgroup-delconsumer for more details.
|
|
3365
|
+
See [valkey.io](https://valkey.io/commands/xgroup-delconsumer) for more details.
|
|
3099
3366
|
|
|
3100
3367
|
Args:
|
|
3101
3368
|
key (TEncodable): The key of the stream.
|
|
@@ -3126,7 +3393,7 @@ class CoreCommands(Protocol):
|
|
|
3126
3393
|
"""
|
|
3127
3394
|
Set the last delivered ID for a consumer group.
|
|
3128
3395
|
|
|
3129
|
-
See https://valkey.io/commands/xgroup-setid for more details.
|
|
3396
|
+
See [valkey.io](https://valkey.io/commands/xgroup-setid) for more details.
|
|
3130
3397
|
|
|
3131
3398
|
Args:
|
|
3132
3399
|
key (TEncodable): The key of the stream.
|
|
@@ -3161,7 +3428,7 @@ class CoreCommands(Protocol):
|
|
|
3161
3428
|
"""
|
|
3162
3429
|
Reads entries from the given streams owned by a consumer group.
|
|
3163
3430
|
|
|
3164
|
-
See https://valkey.io/commands/xreadgroup for more details.
|
|
3431
|
+
See [valkey.io](https://valkey.io/commands/xreadgroup) for more details.
|
|
3165
3432
|
|
|
3166
3433
|
Note:
|
|
3167
3434
|
When in cluster mode, all keys in `keys_and_ids` must map to the same hash slot.
|
|
@@ -3175,8 +3442,9 @@ class CoreCommands(Protocol):
|
|
|
3175
3442
|
|
|
3176
3443
|
Returns:
|
|
3177
3444
|
Optional[Mapping[bytes, Mapping[bytes, Optional[List[List[bytes]]]]]]: A mapping of stream keys, to a mapping of
|
|
3178
|
-
|
|
3179
|
-
|
|
3445
|
+
stream IDs, to a list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3446
|
+
|
|
3447
|
+
Returns None if the BLOCK option is given and a timeout occurs, or if there is no stream that can be served.
|
|
3180
3448
|
|
|
3181
3449
|
Examples:
|
|
3182
3450
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="1-0"))
|
|
@@ -3212,7 +3480,7 @@ class CoreCommands(Protocol):
|
|
|
3212
3480
|
This command should be called on pending messages so that such messages do not get processed again by the
|
|
3213
3481
|
consumer group.
|
|
3214
3482
|
|
|
3215
|
-
See https://valkey.io/commands/xack for more details.
|
|
3483
|
+
See [valkey.io](https://valkey.io/commands/xack) for more details.
|
|
3216
3484
|
|
|
3217
3485
|
Args:
|
|
3218
3486
|
key (TEncodable): The key of the stream.
|
|
@@ -3249,7 +3517,7 @@ class CoreCommands(Protocol):
|
|
|
3249
3517
|
"""
|
|
3250
3518
|
Returns stream message summary information for pending messages for the given consumer group.
|
|
3251
3519
|
|
|
3252
|
-
See https://valkey.io/commands/xpending for more details.
|
|
3520
|
+
See [valkey.io](https://valkey.io/commands/xpending) for more details.
|
|
3253
3521
|
|
|
3254
3522
|
Args:
|
|
3255
3523
|
key (TEncodable): The key of the stream.
|
|
@@ -3257,14 +3525,15 @@ class CoreCommands(Protocol):
|
|
|
3257
3525
|
|
|
3258
3526
|
Returns:
|
|
3259
3527
|
List[Union[int, bytes, List[List[bytes]], None]]: A list that includes the summary of pending messages, with the
|
|
3260
|
-
|
|
3528
|
+
format `[num_group_messages, start_id, end_id, [[consumer_name, num_consumer_messages]]]`, where:
|
|
3529
|
+
|
|
3261
3530
|
- `num_group_messages`: The total number of pending messages for this consumer group.
|
|
3262
3531
|
- `start_id`: The smallest ID among the pending messages.
|
|
3263
3532
|
- `end_id`: The greatest ID among the pending messages.
|
|
3264
3533
|
- `[[consumer_name, num_consumer_messages]]`: A 2D list of every consumer in the consumer group with at
|
|
3265
|
-
|
|
3534
|
+
least one pending message, and the number of pending messages it has.
|
|
3266
3535
|
|
|
3267
|
-
|
|
3536
|
+
If there are no pending messages for the given consumer group, `[0, None, None, None]` will be returned.
|
|
3268
3537
|
|
|
3269
3538
|
Examples:
|
|
3270
3539
|
>>> await client.xpending("my_stream", "my_group")
|
|
@@ -3287,34 +3556,46 @@ class CoreCommands(Protocol):
|
|
|
3287
3556
|
"""
|
|
3288
3557
|
Returns an extended form of stream message information for pending messages matching a given range of IDs.
|
|
3289
3558
|
|
|
3290
|
-
See https://valkey.io/commands/xpending for more details.
|
|
3559
|
+
See [valkey.io](https://valkey.io/commands/xpending) for more details.
|
|
3291
3560
|
|
|
3292
3561
|
Args:
|
|
3293
3562
|
key (TEncodable): The key of the stream.
|
|
3294
3563
|
group_name (TEncodable): The consumer group name.
|
|
3295
3564
|
start (StreamRangeBound): The starting stream ID bound for the range.
|
|
3565
|
+
|
|
3296
3566
|
- Use `IdBound` to specify a stream ID.
|
|
3297
3567
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
3298
3568
|
- Use `MinId` to start with the minimum available ID.
|
|
3569
|
+
|
|
3299
3570
|
end (StreamRangeBound): The ending stream ID bound for the range.
|
|
3571
|
+
|
|
3300
3572
|
- Use `IdBound` to specify a stream ID.
|
|
3301
3573
|
- Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
|
|
3302
3574
|
- Use `MaxId` to end with the maximum available ID.
|
|
3575
|
+
|
|
3303
3576
|
count (int): Limits the number of messages returned.
|
|
3304
3577
|
options (Optional[StreamPendingOptions]): The stream pending options.
|
|
3305
3578
|
|
|
3306
3579
|
Returns:
|
|
3307
3580
|
List[List[Union[bytes, int]]]: A list of lists, where each inner list is a length 4 list containing extended
|
|
3308
|
-
|
|
3581
|
+
message information with the format `[[id, consumer_name, time_elapsed, num_delivered]]`, where:
|
|
3582
|
+
|
|
3309
3583
|
- `id`: The ID of the message.
|
|
3310
3584
|
- `consumer_name`: The name of the consumer that fetched the message and has still to acknowledge it. We
|
|
3311
|
-
|
|
3585
|
+
call it the current owner of the message.
|
|
3312
3586
|
- `time_elapsed`: The number of milliseconds that elapsed since the last time this message was delivered
|
|
3313
|
-
|
|
3587
|
+
to this consumer.
|
|
3314
3588
|
- `num_delivered`: The number of times this message was delivered.
|
|
3315
3589
|
|
|
3316
3590
|
Examples:
|
|
3317
|
-
>>> await client.xpending_range(
|
|
3591
|
+
>>> await client.xpending_range(
|
|
3592
|
+
... "my_stream",
|
|
3593
|
+
... "my_group",
|
|
3594
|
+
... MinId(),
|
|
3595
|
+
... MaxId(),
|
|
3596
|
+
... 10,
|
|
3597
|
+
... StreamPendingOptions(consumer_name="my_consumer")
|
|
3598
|
+
... )
|
|
3318
3599
|
[[b"1-0", b"my_consumer", 1234, 1], [b"1-1", b"my_consumer", 1123, 1]]
|
|
3319
3600
|
# Extended stream entry information for the pending entries associated with "my_consumer".
|
|
3320
3601
|
"""
|
|
@@ -3336,7 +3617,7 @@ class CoreCommands(Protocol):
|
|
|
3336
3617
|
"""
|
|
3337
3618
|
Changes the ownership of a pending message.
|
|
3338
3619
|
|
|
3339
|
-
See https://valkey.io/commands/xclaim for more details.
|
|
3620
|
+
See [valkey.io](https://valkey.io/commands/xclaim) for more details.
|
|
3340
3621
|
|
|
3341
3622
|
Args:
|
|
3342
3623
|
key (TEncodable): The key of the stream.
|
|
@@ -3347,11 +3628,15 @@ class CoreCommands(Protocol):
|
|
|
3347
3628
|
options (Optional[StreamClaimOptions]): Stream claim options.
|
|
3348
3629
|
|
|
3349
3630
|
Returns:
|
|
3350
|
-
Mapping[bytes, List[List[bytes]]]: A Mapping of message entries with the format
|
|
3351
|
-
|
|
3631
|
+
Mapping[bytes, List[List[bytes]]]: A Mapping of message entries with the format::
|
|
3632
|
+
|
|
3633
|
+
{"entryId": [["entry", "data"], ...], ...}
|
|
3634
|
+
|
|
3635
|
+
that are claimed by the consumer.
|
|
3352
3636
|
|
|
3353
3637
|
Examples:
|
|
3354
|
-
|
|
3638
|
+
read messages from streamId for consumer1:
|
|
3639
|
+
|
|
3355
3640
|
>>> await client.xreadgroup({"mystream": ">"}, "mygroup", "consumer1")
|
|
3356
3641
|
{
|
|
3357
3642
|
b"mystream": {
|
|
@@ -3386,7 +3671,7 @@ class CoreCommands(Protocol):
|
|
|
3386
3671
|
Changes the ownership of a pending message. This function returns a List with
|
|
3387
3672
|
only the message/entry IDs, and is equivalent to using JUSTID in the Valkey API.
|
|
3388
3673
|
|
|
3389
|
-
See https://valkey.io/commands/xclaim for more details.
|
|
3674
|
+
See [valkey.io](https://valkey.io/commands/xclaim) for more details.
|
|
3390
3675
|
|
|
3391
3676
|
Args:
|
|
3392
3677
|
key (TEncodable): The key of the stream.
|
|
@@ -3400,7 +3685,8 @@ class CoreCommands(Protocol):
|
|
|
3400
3685
|
List[bytes]: A List of message ids claimed by the consumer.
|
|
3401
3686
|
|
|
3402
3687
|
Examples:
|
|
3403
|
-
|
|
3688
|
+
read messages from streamId for consumer1:
|
|
3689
|
+
|
|
3404
3690
|
>>> await client.xreadgroup({"mystream": ">"}, "mygroup", "consumer1")
|
|
3405
3691
|
{
|
|
3406
3692
|
b"mystream": {
|
|
@@ -3441,7 +3727,7 @@ class CoreCommands(Protocol):
|
|
|
3441
3727
|
"""
|
|
3442
3728
|
Transfers ownership of pending stream entries that match the specified criteria.
|
|
3443
3729
|
|
|
3444
|
-
See https://valkey.io/commands/xautoclaim for more details.
|
|
3730
|
+
See [valkey.io](https://valkey.io/commands/xautoclaim) for more details.
|
|
3445
3731
|
|
|
3446
3732
|
Args:
|
|
3447
3733
|
key (TEncodable): The key of the stream.
|
|
@@ -3450,21 +3736,23 @@ class CoreCommands(Protocol):
|
|
|
3450
3736
|
min_idle_time_ms (int): Filters the claimed entries to those that have been idle for more than the specified
|
|
3451
3737
|
value.
|
|
3452
3738
|
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.
|
|
3739
|
+
count (Optional[int]): Limits the number of claimed entries to the specified value. Default value is 100.
|
|
3454
3740
|
|
|
3455
3741
|
Returns:
|
|
3456
3742
|
List[Union[bytes, Mapping[bytes, List[List[bytes]]], List[bytes]]]: A list containing the following elements:
|
|
3743
|
+
|
|
3457
3744
|
- A stream ID to be used as the start argument for the next call to `XAUTOCLAIM`. This ID is equivalent
|
|
3458
|
-
|
|
3459
|
-
|
|
3745
|
+
to the next ID in the stream after the entries that were scanned, or "0-0" if the entire stream was
|
|
3746
|
+
scanned.
|
|
3460
3747
|
- A mapping of the claimed entries, with the keys being the claimed entry IDs and the values being a
|
|
3461
|
-
|
|
3748
|
+
2D list of the field-value pairs in the format `[[field1, value1], [field2, value2], ...]`.
|
|
3462
3749
|
- If you are using Valkey 7.0.0 or above, the response list will also include a list containing the
|
|
3463
|
-
|
|
3464
|
-
|
|
3750
|
+
message IDs that were in the Pending Entries List but no longer exist in the stream. These IDs are
|
|
3751
|
+
deleted from the Pending Entries List.
|
|
3465
3752
|
|
|
3466
3753
|
Examples:
|
|
3467
|
-
|
|
3754
|
+
Valkey version < 7.0.0:
|
|
3755
|
+
|
|
3468
3756
|
>>> await client.xautoclaim("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3469
3757
|
[
|
|
3470
3758
|
b"0-0",
|
|
@@ -3478,7 +3766,8 @@ class CoreCommands(Protocol):
|
|
|
3478
3766
|
# Stream entry "1-1" was idle for over an hour and was thus claimed by "my_consumer". The entire stream
|
|
3479
3767
|
# was scanned.
|
|
3480
3768
|
|
|
3481
|
-
|
|
3769
|
+
Valkey version 7.0.0 and above:
|
|
3770
|
+
|
|
3482
3771
|
>>> await client.xautoclaim("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3483
3772
|
[
|
|
3484
3773
|
b"0-0",
|
|
@@ -3525,7 +3814,7 @@ class CoreCommands(Protocol):
|
|
|
3525
3814
|
argument to further specify that the return value should contain a list of claimed IDs without their
|
|
3526
3815
|
field-value info.
|
|
3527
3816
|
|
|
3528
|
-
See https://valkey.io/commands/xautoclaim for more details.
|
|
3817
|
+
See [valkey.io](https://valkey.io/commands/xautoclaim) for more details.
|
|
3529
3818
|
|
|
3530
3819
|
Args:
|
|
3531
3820
|
key (TEncodable): The key of the stream.
|
|
@@ -3534,26 +3823,29 @@ class CoreCommands(Protocol):
|
|
|
3534
3823
|
min_idle_time_ms (int): Filters the claimed entries to those that have been idle for more than the specified
|
|
3535
3824
|
value.
|
|
3536
3825
|
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.
|
|
3826
|
+
count (Optional[int]): Limits the number of claimed entries to the specified value. Default value is 100.
|
|
3538
3827
|
|
|
3539
3828
|
Returns:
|
|
3540
3829
|
List[Union[bytes, List[bytes]]]: A list containing the following elements:
|
|
3830
|
+
|
|
3541
3831
|
- A stream ID to be used as the start argument for the next call to `XAUTOCLAIM`. This ID is equivalent
|
|
3542
|
-
|
|
3543
|
-
|
|
3832
|
+
to the next ID in the stream after the entries that were scanned, or "0-0" if the entire stream was
|
|
3833
|
+
scanned.
|
|
3544
3834
|
- A list of the IDs for the claimed entries.
|
|
3545
3835
|
- If you are using Valkey 7.0.0 or above, the response list will also include a list containing the
|
|
3546
|
-
|
|
3547
|
-
|
|
3836
|
+
message IDs that were in the Pending Entries List but no longer exist in the stream. These IDs are
|
|
3837
|
+
deleted from the Pending Entries List.
|
|
3548
3838
|
|
|
3549
3839
|
Examples:
|
|
3550
|
-
|
|
3840
|
+
Valkey version < 7.0.0:
|
|
3841
|
+
|
|
3551
3842
|
>>> await client.xautoclaim_just_id("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3552
3843
|
[b"0-0", [b"1-1"]]
|
|
3553
3844
|
# Stream entry "1-1" was idle for over an hour and was thus claimed by "my_consumer". The entire stream
|
|
3554
3845
|
# was scanned.
|
|
3555
3846
|
|
|
3556
|
-
|
|
3847
|
+
Valkey version 7.0.0 and above:
|
|
3848
|
+
|
|
3557
3849
|
>>> await client.xautoclaim_just_id("my_stream", "my_group", "my_consumer", 3_600_000, "0-0")
|
|
3558
3850
|
[b"0-0", [b"1-1"], [b"1-2"]]
|
|
3559
3851
|
# Stream entry "1-1" was idle for over an hour and was thus claimed by "my_consumer". The entire stream
|
|
@@ -3586,14 +3878,14 @@ class CoreCommands(Protocol):
|
|
|
3586
3878
|
"""
|
|
3587
3879
|
Returns the list of all consumer groups and their attributes for the stream stored at `key`.
|
|
3588
3880
|
|
|
3589
|
-
See https://valkey.io/commands/xinfo-groups for more details.
|
|
3881
|
+
See [valkey.io](https://valkey.io/commands/xinfo-groups) for more details.
|
|
3590
3882
|
|
|
3591
3883
|
Args:
|
|
3592
3884
|
key (TEncodable): The key of the stream.
|
|
3593
3885
|
|
|
3594
3886
|
Returns:
|
|
3595
3887
|
List[Mapping[bytes, Union[bytes, int, None]]]: A list of mappings, where each mapping represents the
|
|
3596
|
-
|
|
3888
|
+
attributes of a consumer group for the stream at `key`.
|
|
3597
3889
|
|
|
3598
3890
|
Examples:
|
|
3599
3891
|
>>> await client.xinfo_groups("my_stream")
|
|
@@ -3631,7 +3923,7 @@ class CoreCommands(Protocol):
|
|
|
3631
3923
|
Returns the list of all consumers and their attributes for the given consumer group of the stream stored at
|
|
3632
3924
|
`key`.
|
|
3633
3925
|
|
|
3634
|
-
See https://valkey.io/commands/xinfo-consumers for more details.
|
|
3926
|
+
See [valkey.io](https://valkey.io/commands/xinfo-consumers) for more details.
|
|
3635
3927
|
|
|
3636
3928
|
Args:
|
|
3637
3929
|
key (TEncodable): The key of the stream.
|
|
@@ -3639,7 +3931,7 @@ class CoreCommands(Protocol):
|
|
|
3639
3931
|
|
|
3640
3932
|
Returns:
|
|
3641
3933
|
List[Mapping[bytes, Union[bytes, int]]]: A list of mappings, where each mapping contains the attributes of a
|
|
3642
|
-
|
|
3934
|
+
consumer for the given consumer group of the stream at `key`.
|
|
3643
3935
|
|
|
3644
3936
|
Examples:
|
|
3645
3937
|
>>> await client.xinfo_consumers("my_stream", "my_group")
|
|
@@ -3671,14 +3963,14 @@ class CoreCommands(Protocol):
|
|
|
3671
3963
|
"""
|
|
3672
3964
|
Returns information about the stream stored at `key`. To get more detailed information, use `xinfo_stream_full`.
|
|
3673
3965
|
|
|
3674
|
-
See https://valkey.io/commands/xinfo-stream for more details.
|
|
3966
|
+
See [valkey.io](https://valkey.io/commands/xinfo-stream) for more details.
|
|
3675
3967
|
|
|
3676
3968
|
Args:
|
|
3677
3969
|
key (TEncodable): The key of the stream.
|
|
3678
3970
|
|
|
3679
3971
|
Returns:
|
|
3680
3972
|
TXInfoStreamResponse: A mapping of stream information for the given `key`. See the example for a sample
|
|
3681
|
-
|
|
3973
|
+
response.
|
|
3682
3974
|
|
|
3683
3975
|
Examples:
|
|
3684
3976
|
>>> await client.xinfo_stream("my_stream")
|
|
@@ -3716,7 +4008,7 @@ class CoreCommands(Protocol):
|
|
|
3716
4008
|
"""
|
|
3717
4009
|
Returns verbose information about the stream stored at `key`.
|
|
3718
4010
|
|
|
3719
|
-
See https://valkey.io/commands/xinfo-stream for more details.
|
|
4011
|
+
See [valkey.io](https://valkey.io/commands/xinfo-stream) for more details.
|
|
3720
4012
|
|
|
3721
4013
|
Args:
|
|
3722
4014
|
key (TEncodable): The key of the stream.
|
|
@@ -3725,7 +4017,7 @@ class CoreCommands(Protocol):
|
|
|
3725
4017
|
|
|
3726
4018
|
Returns:
|
|
3727
4019
|
TXInfoStreamFullResponse: A mapping of detailed stream information for the given `key`. See the example for
|
|
3728
|
-
|
|
4020
|
+
a sample response.
|
|
3729
4021
|
|
|
3730
4022
|
Examples:
|
|
3731
4023
|
>>> await client.xinfo_stream_full("my_stream")
|
|
@@ -3815,25 +4107,43 @@ class CoreCommands(Protocol):
|
|
|
3815
4107
|
Adds geospatial members with their positions to the specified sorted set stored at `key`.
|
|
3816
4108
|
If a member is already a part of the sorted set, its position is updated.
|
|
3817
4109
|
|
|
3818
|
-
See https://valkey.io/commands/geoadd for more details.
|
|
4110
|
+
See [valkey.io](https://valkey.io/commands/geoadd) for more details.
|
|
3819
4111
|
|
|
3820
4112
|
Args:
|
|
3821
4113
|
key (TEncodable): The key of the sorted set.
|
|
3822
|
-
members_geospatialdata (Mapping[TEncodable, GeospatialData]): A mapping of member names to their corresponding
|
|
3823
|
-
|
|
4114
|
+
members_geospatialdata (Mapping[TEncodable, GeospatialData]): A mapping of member names to their corresponding
|
|
4115
|
+
positions. See `GeospatialData`. The command will report an error when the user attempts to index coordinates
|
|
4116
|
+
outside the specified ranges.
|
|
3824
4117
|
existing_options (Optional[ConditionalChange]): Options for handling existing members.
|
|
4118
|
+
|
|
3825
4119
|
- NX: Only add new elements.
|
|
3826
4120
|
- XX: Only update existing elements.
|
|
3827
|
-
|
|
4121
|
+
|
|
4122
|
+
changed (bool): Modify the return value to return the number of changed elements, instead of the number of new
|
|
4123
|
+
elements added.
|
|
3828
4124
|
|
|
3829
4125
|
Returns:
|
|
3830
4126
|
int: The number of elements added to the sorted set.
|
|
4127
|
+
|
|
3831
4128
|
If `changed` is set, returns the number of elements updated in the sorted set.
|
|
3832
4129
|
|
|
3833
4130
|
Examples:
|
|
3834
|
-
>>> await client.geoadd(
|
|
4131
|
+
>>> await client.geoadd(
|
|
4132
|
+
... "my_sorted_set",
|
|
4133
|
+
... {
|
|
4134
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4135
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4136
|
+
... }
|
|
4137
|
+
... )
|
|
3835
4138
|
2 # Indicates that two elements have been added to the sorted set "my_sorted_set".
|
|
3836
|
-
>>> await client.geoadd(
|
|
4139
|
+
>>> await client.geoadd(
|
|
4140
|
+
... "my_sorted_set",
|
|
4141
|
+
... {
|
|
4142
|
+
... "Palermo": GeospatialData(14.361389, 38.115556)
|
|
4143
|
+
... },
|
|
4144
|
+
... existing_options=ConditionalChange.XX,
|
|
4145
|
+
... changed=True
|
|
4146
|
+
... )
|
|
3837
4147
|
1 # Updates the position of an existing member in the sorted set "my_sorted_set".
|
|
3838
4148
|
"""
|
|
3839
4149
|
args = [key]
|
|
@@ -3865,7 +4175,7 @@ class CoreCommands(Protocol):
|
|
|
3865
4175
|
"""
|
|
3866
4176
|
Returns the distance between two members in the geospatial index stored at `key`.
|
|
3867
4177
|
|
|
3868
|
-
See https://valkey.io/commands/geodist for more details.
|
|
4178
|
+
See [valkey.io](https://valkey.io/commands/geodist) for more details.
|
|
3869
4179
|
|
|
3870
4180
|
Args:
|
|
3871
4181
|
key (TEncodable): The key of the sorted set.
|
|
@@ -3876,10 +4186,17 @@ class CoreCommands(Protocol):
|
|
|
3876
4186
|
|
|
3877
4187
|
Returns:
|
|
3878
4188
|
Optional[float]: The distance between `member1` and `member2`.
|
|
4189
|
+
|
|
3879
4190
|
If one or both members do not exist, or if the key does not exist, returns None.
|
|
3880
4191
|
|
|
3881
4192
|
Examples:
|
|
3882
|
-
>>> await client.geoadd(
|
|
4193
|
+
>>> await client.geoadd(
|
|
4194
|
+
... "my_geo_set",
|
|
4195
|
+
... {
|
|
4196
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4197
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4198
|
+
... }
|
|
4199
|
+
... )
|
|
3883
4200
|
>>> await client.geodist("my_geo_set", "Palermo", "Catania")
|
|
3884
4201
|
166274.1516 # Indicates the distance between "Palermo" and "Catania" in meters.
|
|
3885
4202
|
>>> await client.geodist("my_geo_set", "Palermo", "Palermo", unit=GeoUnit.KILOMETERS)
|
|
@@ -3903,18 +4220,26 @@ class CoreCommands(Protocol):
|
|
|
3903
4220
|
Returns the GeoHash bytes strings representing the positions of all the specified members in the sorted set stored at
|
|
3904
4221
|
`key`.
|
|
3905
4222
|
|
|
3906
|
-
See https://valkey.io/commands/geohash for more details.
|
|
4223
|
+
See [valkey.io](https://valkey.io/commands/geohash) for more details.
|
|
3907
4224
|
|
|
3908
4225
|
Args:
|
|
3909
4226
|
key (TEncodable): The key of the sorted set.
|
|
3910
4227
|
members (List[TEncodable]): The list of members whose GeoHash bytes strings are to be retrieved.
|
|
3911
4228
|
|
|
3912
4229
|
Returns:
|
|
3913
|
-
List[Optional[bytes]]: A list of GeoHash bytes strings representing the positions of the specified members stored
|
|
4230
|
+
List[Optional[bytes]]: A list of GeoHash bytes strings representing the positions of the specified members stored
|
|
4231
|
+
at `key`.
|
|
4232
|
+
|
|
3914
4233
|
If a member does not exist in the sorted set, a None value is returned for that member.
|
|
3915
4234
|
|
|
3916
4235
|
Examples:
|
|
3917
|
-
>>> await client.geoadd(
|
|
4236
|
+
>>> await client.geoadd(
|
|
4237
|
+
... "my_geo_sorted_set",
|
|
4238
|
+
... {
|
|
4239
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4240
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4241
|
+
... }
|
|
4242
|
+
... )
|
|
3918
4243
|
>>> await client.geohash("my_geo_sorted_set", ["Palermo", "Catania", "some city])
|
|
3919
4244
|
["sqc8b49rny0", "sqdtr74hyu0", None] # Indicates the GeoHash bytes strings for the specified members.
|
|
3920
4245
|
"""
|
|
@@ -3929,10 +4254,10 @@ class CoreCommands(Protocol):
|
|
|
3929
4254
|
members: List[TEncodable],
|
|
3930
4255
|
) -> List[Optional[List[float]]]:
|
|
3931
4256
|
"""
|
|
3932
|
-
Returns the positions (longitude and latitude) of all the given members of a geospatial index in the sorted set stored
|
|
3933
|
-
`key`.
|
|
4257
|
+
Returns the positions (longitude and latitude) of all the given members of a geospatial index in the sorted set stored
|
|
4258
|
+
at `key`.
|
|
3934
4259
|
|
|
3935
|
-
See https://valkey.io/commands/geopos for more details.
|
|
4260
|
+
See [valkey.io](https://valkey.io/commands/geopos) for more details.
|
|
3936
4261
|
|
|
3937
4262
|
Args:
|
|
3938
4263
|
key (TEncodable): The key of the sorted set.
|
|
@@ -3940,10 +4265,17 @@ class CoreCommands(Protocol):
|
|
|
3940
4265
|
|
|
3941
4266
|
Returns:
|
|
3942
4267
|
List[Optional[List[float]]]: A list of positions (longitude and latitude) corresponding to the given members.
|
|
4268
|
+
|
|
3943
4269
|
If a member does not exist, its position will be None.
|
|
3944
4270
|
|
|
3945
4271
|
Example:
|
|
3946
|
-
>>> await client.geoadd(
|
|
4272
|
+
>>> await client.geoadd(
|
|
4273
|
+
... "my_geo_sorted_set",
|
|
4274
|
+
... {
|
|
4275
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4276
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4277
|
+
... }
|
|
4278
|
+
... )
|
|
3947
4279
|
>>> await client.geopos("my_geo_sorted_set", ["Palermo", "Catania", "NonExisting"])
|
|
3948
4280
|
[[13.36138933897018433, 38.11555639549629859], [15.08726745843887329, 37.50266842333162032], None]
|
|
3949
4281
|
"""
|
|
@@ -3964,9 +4296,10 @@ class CoreCommands(Protocol):
|
|
|
3964
4296
|
with_hash: bool = False,
|
|
3965
4297
|
) -> List[Union[bytes, List[Union[bytes, float, int, List[float]]]]]:
|
|
3966
4298
|
"""
|
|
3967
|
-
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4299
|
+
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4300
|
+
area.
|
|
3968
4301
|
|
|
3969
|
-
See https://valkey.io/commands/geosearch/ for more details.
|
|
4302
|
+
See [valkey.io](https://valkey.io/commands/geosearch/) for more details.
|
|
3970
4303
|
|
|
3971
4304
|
Args:
|
|
3972
4305
|
key (TEncodable): The key of the sorted set representing geospatial data.
|
|
@@ -3976,8 +4309,10 @@ class CoreCommands(Protocol):
|
|
|
3976
4309
|
For circular area search, see `GeoSearchByRadius`.
|
|
3977
4310
|
For rectangular area search, see `GeoSearchByBox`.
|
|
3978
4311
|
order_by (Optional[OrderBy]): Specifies the order in which the results should be returned.
|
|
3979
|
-
|
|
3980
|
-
|
|
4312
|
+
|
|
4313
|
+
- `ASC`: Sorts items from the nearest to the farthest, relative to the center point.
|
|
4314
|
+
- `DESC`: Sorts items from the farthest to the nearest, relative to the center point.
|
|
4315
|
+
|
|
3981
4316
|
If not specified, the results would be unsorted.
|
|
3982
4317
|
count (Optional[GeoSearchCount]): Specifies the maximum number of results to return. See `GeoSearchCount`.
|
|
3983
4318
|
If not specified, return all results.
|
|
@@ -3987,19 +4322,45 @@ class CoreCommands(Protocol):
|
|
|
3987
4322
|
with_hash (bool): Whether to include geohash of the returned items. Defaults to False.
|
|
3988
4323
|
|
|
3989
4324
|
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
|
-
|
|
4325
|
+
List[Union[bytes, List[Union[bytes, float, int, List[float]]]]]: By default, returns a list of members (locations)
|
|
4326
|
+
names.
|
|
4327
|
+
|
|
4328
|
+
If any of `with_coord`, `with_dist` or `with_hash` are True, returns an array of arrays, we're each sub array
|
|
4329
|
+
represents a single item in the following order:
|
|
4330
|
+
|
|
4331
|
+
- (bytes): The member (location) name.
|
|
4332
|
+
- (float): The distance from the center as a floating point number, in the same unit specified in the radius,
|
|
4333
|
+
if `with_dist` is set to True.
|
|
4334
|
+
- (int): The Geohash integer, if `with_hash` is set to True.
|
|
4335
|
+
- List[float]: The coordinates as a two item [longitude,latitude] array, if `with_coord` is set to True.
|
|
4336
|
+
|
|
4337
|
+
Examples:
|
|
4338
|
+
>>> await client.geoadd(
|
|
4339
|
+
... "my_geo_sorted_set",
|
|
4340
|
+
... {
|
|
4341
|
+
... "edge1": GeospatialData(12.758489, 38.788135),
|
|
4342
|
+
... "edge2": GeospatialData(17.241510, 38.788135)
|
|
4343
|
+
... }
|
|
4344
|
+
... )
|
|
4345
|
+
>>> await client.geoadd(
|
|
4346
|
+
... "my_geo_sorted_set",
|
|
4347
|
+
... {
|
|
4348
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4349
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4350
|
+
... }
|
|
4351
|
+
... )
|
|
4000
4352
|
>>> 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
|
-
|
|
4353
|
+
['Palermo', 'Catania'] # Returned the locations names within the radius of 175 miles, with the center being
|
|
4354
|
+
# 'Catania' from farthest to nearest.
|
|
4355
|
+
>>> await client.geosearch(
|
|
4356
|
+
... "my_geo_sorted_set",
|
|
4357
|
+
... GeospatialData(15, 37),
|
|
4358
|
+
... GeoSearchByBox(400, 400, GeoUnit.KILOMETERS),
|
|
4359
|
+
... OrderBy.DESC,
|
|
4360
|
+
... with_coord=true,
|
|
4361
|
+
... with_dist=true,
|
|
4362
|
+
... with_hash=true
|
|
4363
|
+
... )
|
|
4003
4364
|
[
|
|
4004
4365
|
[
|
|
4005
4366
|
b"Catania",
|
|
@@ -4017,7 +4378,8 @@ class CoreCommands(Protocol):
|
|
|
4017
4378
|
b"edge1",
|
|
4018
4379
|
[279.7405, 3479273021651468, [12.75848776102066, 38.78813451624225]],
|
|
4019
4380
|
],
|
|
4020
|
-
] # Returns locations within the square box of 400 km, with the center being a specific point, from nearest
|
|
4381
|
+
] # Returns locations within the square box of 400 km, with the center being a specific point, from nearest
|
|
4382
|
+
# to farthest with the dist, hash and coords.
|
|
4021
4383
|
|
|
4022
4384
|
Since: Valkey version 6.2.0.
|
|
4023
4385
|
"""
|
|
@@ -4047,7 +4409,8 @@ class CoreCommands(Protocol):
|
|
|
4047
4409
|
store_dist: bool = False,
|
|
4048
4410
|
) -> int:
|
|
4049
4411
|
"""
|
|
4050
|
-
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4412
|
+
Searches for members in a sorted set stored at `key` representing geospatial data within a circular or rectangular
|
|
4413
|
+
area and stores the result in `destination`.
|
|
4051
4414
|
If `destination` already exists, it is overwritten. Otherwise, a new sorted set will be created.
|
|
4052
4415
|
|
|
4053
4416
|
To get the result directly, see `geosearch`.
|
|
@@ -4055,34 +4418,55 @@ class CoreCommands(Protocol):
|
|
|
4055
4418
|
Note:
|
|
4056
4419
|
When in cluster mode, both `source` and `destination` must map to the same hash slot.
|
|
4057
4420
|
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4421
|
+
Args:
|
|
4422
|
+
destination (TEncodable): The key to store the search results.
|
|
4423
|
+
source (TEncodable): The key of the sorted set representing geospatial data to search from.
|
|
4424
|
+
search_from (Union[str, bytes, GeospatialData]): The location to search from. Can be specified either as a
|
|
4425
|
+
member from the sorted set or as a geospatial data (see `GeospatialData`).
|
|
4426
|
+
search_by (Union[GeoSearchByRadius, GeoSearchByBox]): The search criteria.
|
|
4427
|
+
For circular area search, see `GeoSearchByRadius`.
|
|
4428
|
+
For rectangular area search, see `GeoSearchByBox`.
|
|
4429
|
+
count (Optional[GeoSearchCount]): Specifies the maximum number of results to store. See `GeoSearchCount`.
|
|
4430
|
+
If not specified, stores all results.
|
|
4431
|
+
store_dist (bool): Determines what is stored as the sorted set score. Defaults to False.
|
|
4432
|
+
|
|
4433
|
+
- If set to False, the geohash of the location will be stored as the sorted set score.
|
|
4434
|
+
- If set to True, the distance from the center of the shape (circle or box) will be stored as the sorted
|
|
4435
|
+
set score.
|
|
4436
|
+
The distance is represented as a floating-point number in the same unit specified for that shape.
|
|
4072
4437
|
|
|
4073
4438
|
Returns:
|
|
4074
4439
|
int: The number of elements in the resulting sorted set stored at `destination`.
|
|
4075
4440
|
|
|
4076
4441
|
Examples:
|
|
4077
|
-
>>> await client.geoadd(
|
|
4078
|
-
|
|
4442
|
+
>>> await client.geoadd(
|
|
4443
|
+
... "my_geo_sorted_set",
|
|
4444
|
+
... {
|
|
4445
|
+
... "Palermo": GeospatialData(13.361389, 38.115556),
|
|
4446
|
+
... "Catania": GeospatialData(15.087269, 37.502669)
|
|
4447
|
+
... }
|
|
4448
|
+
... )
|
|
4449
|
+
>>> await client.geosearchstore(
|
|
4450
|
+
... "my_dest_sorted_set",
|
|
4451
|
+
... "my_geo_sorted_set",
|
|
4452
|
+
... "Catania",
|
|
4453
|
+
... GeoSearchByRadius(175, GeoUnit.MILES)
|
|
4454
|
+
... )
|
|
4079
4455
|
2 # Number of elements stored in "my_dest_sorted_set".
|
|
4080
4456
|
>>> 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
|
-
|
|
4457
|
+
{b"Palermo": 3479099956230698.0, b"Catania": 3479447370796909.0} # The elements within te search area, with
|
|
4458
|
+
# their geohash as score.
|
|
4459
|
+
>>> await client.geosearchstore(
|
|
4460
|
+
... "my_dest_sorted_set",
|
|
4461
|
+
... "my_geo_sorted_set",
|
|
4462
|
+
... GeospatialData(15, 37),
|
|
4463
|
+
... GeoSearchByBox(400, 400, GeoUnit.KILOMETERS),
|
|
4464
|
+
... store_dist=True
|
|
4465
|
+
... )
|
|
4083
4466
|
2 # Number of elements stored in "my_dest_sorted_set", with distance as score.
|
|
4084
4467
|
>>> 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
|
|
4468
|
+
{b"Catania": 56.4412578701582, b"Palermo": 190.44242984775784} # The elements within te search area, with the
|
|
4469
|
+
# distance as score.
|
|
4086
4470
|
|
|
4087
4471
|
Since: Valkey version 6.2.0.
|
|
4088
4472
|
"""
|
|
@@ -4115,27 +4499,41 @@ class CoreCommands(Protocol):
|
|
|
4115
4499
|
Adds members with their scores to the sorted set stored at `key`.
|
|
4116
4500
|
If a member is already a part of the sorted set, its score is updated.
|
|
4117
4501
|
|
|
4118
|
-
See https://valkey.io/commands/zadd/ for more details.
|
|
4502
|
+
See [valkey.io](https://valkey.io/commands/zadd/) for more details.
|
|
4119
4503
|
|
|
4120
4504
|
Args:
|
|
4121
4505
|
key (TEncodable): The key of the sorted set.
|
|
4122
4506
|
members_scores (Mapping[TEncodable, float]): A mapping of members to their corresponding scores.
|
|
4123
4507
|
existing_options (Optional[ConditionalChange]): Options for handling existing members.
|
|
4508
|
+
|
|
4124
4509
|
- NX: Only add new elements.
|
|
4125
4510
|
- XX: Only update existing elements.
|
|
4511
|
+
|
|
4126
4512
|
update_condition (Optional[UpdateOptions]): Options for updating scores.
|
|
4513
|
+
|
|
4127
4514
|
- GT: Only update scores greater than the current values.
|
|
4128
4515
|
- LT: Only update scores less than the current values.
|
|
4129
|
-
|
|
4516
|
+
|
|
4517
|
+
changed (bool): Modify the return value to return the number of changed elements, instead of the number of new
|
|
4518
|
+
elements added.
|
|
4130
4519
|
|
|
4131
4520
|
Returns:
|
|
4132
4521
|
int: The number of elements added to the sorted set.
|
|
4522
|
+
|
|
4133
4523
|
If `changed` is set, returns the number of elements updated in the sorted set.
|
|
4134
4524
|
|
|
4135
4525
|
Examples:
|
|
4136
4526
|
>>> await client.zadd("my_sorted_set", {"member1": 10.5, "member2": 8.2})
|
|
4137
4527
|
2 # Indicates that two elements have been added to the sorted set "my_sorted_set."
|
|
4138
|
-
>>> await client.zadd(
|
|
4528
|
+
>>> await client.zadd(
|
|
4529
|
+
... "existing_sorted_set",
|
|
4530
|
+
... {
|
|
4531
|
+
... "member1": 15.0,
|
|
4532
|
+
... "member2": 5.5
|
|
4533
|
+
... },
|
|
4534
|
+
... existing_options=ConditionalChange.XX,
|
|
4535
|
+
... changed=True
|
|
4536
|
+
... )
|
|
4139
4537
|
2 # Updates the scores of two existing members in the sorted set "existing_sorted_set."
|
|
4140
4538
|
"""
|
|
4141
4539
|
args = [key]
|
|
@@ -4175,24 +4573,29 @@ class CoreCommands(Protocol):
|
|
|
4175
4573
|
) -> Optional[float]:
|
|
4176
4574
|
"""
|
|
4177
4575
|
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
|
|
4576
|
+
If `member` does not exist in the sorted set, it is added with `increment` as its score (as if its previous score
|
|
4577
|
+
was 0.0).
|
|
4179
4578
|
If `key` does not exist, a new sorted set with the specified member as its sole member is created.
|
|
4180
4579
|
|
|
4181
|
-
See https://valkey.io/commands/zadd/ for more details.
|
|
4580
|
+
See [valkey.io](https://valkey.io/commands/zadd/) for more details.
|
|
4182
4581
|
|
|
4183
4582
|
Args:
|
|
4184
4583
|
key (TEncodable): The key of the sorted set.
|
|
4185
4584
|
member (TEncodable): A member in the sorted set to increment.
|
|
4186
4585
|
increment (float): The score to increment the member.
|
|
4187
4586
|
existing_options (Optional[ConditionalChange]): Options for handling the member's existence.
|
|
4587
|
+
|
|
4188
4588
|
- NX: Only increment a member that doesn't exist.
|
|
4189
4589
|
- XX: Only increment an existing member.
|
|
4590
|
+
|
|
4190
4591
|
update_condition (Optional[UpdateOptions]): Options for updating the score.
|
|
4592
|
+
|
|
4191
4593
|
- GT: Only increment the score of the member if the new score will be greater than the current score.
|
|
4192
4594
|
- LT: Only increment (decrement) the score of the member if the new score will be less than the current score.
|
|
4193
4595
|
|
|
4194
4596
|
Returns:
|
|
4195
4597
|
Optional[float]: The score of the member.
|
|
4598
|
+
|
|
4196
4599
|
If there was a conflict with choosing the XX/NX/LT/GT options, the operation aborts and None is returned.
|
|
4197
4600
|
|
|
4198
4601
|
Examples:
|
|
@@ -4227,13 +4630,14 @@ class CoreCommands(Protocol):
|
|
|
4227
4630
|
"""
|
|
4228
4631
|
Returns the cardinality (number of elements) of the sorted set stored at `key`.
|
|
4229
4632
|
|
|
4230
|
-
See https://valkey.io/commands/zcard/ for more details.
|
|
4633
|
+
See [valkey.io](https://valkey.io/commands/zcard/) for more details.
|
|
4231
4634
|
|
|
4232
4635
|
Args:
|
|
4233
4636
|
key (TEncodable): The key of the sorted set.
|
|
4234
4637
|
|
|
4235
4638
|
Returns:
|
|
4236
4639
|
int: The number of elements in the sorted set.
|
|
4640
|
+
|
|
4237
4641
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
4238
4642
|
|
|
4239
4643
|
Examples:
|
|
@@ -4253,7 +4657,7 @@ class CoreCommands(Protocol):
|
|
|
4253
4657
|
"""
|
|
4254
4658
|
Returns the number of members in the sorted set stored at `key` with scores between `min_score` and `max_score`.
|
|
4255
4659
|
|
|
4256
|
-
See https://valkey.io/commands/zcount/ for more details.
|
|
4660
|
+
See [valkey.io](https://valkey.io/commands/zcount/) for more details.
|
|
4257
4661
|
|
|
4258
4662
|
Args:
|
|
4259
4663
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4266,23 +4670,30 @@ class CoreCommands(Protocol):
|
|
|
4266
4670
|
|
|
4267
4671
|
Returns:
|
|
4268
4672
|
int: The number of members in the specified score range.
|
|
4673
|
+
|
|
4269
4674
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
4675
|
+
|
|
4270
4676
|
If `max_score` < `min_score`, 0 is returned.
|
|
4271
4677
|
|
|
4272
4678
|
Examples:
|
|
4273
4679
|
>>> 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
|
-
|
|
4680
|
+
2 # Indicates that there are 2 members with scores between 5.0 (not exclusive) and +inf in the sorted set
|
|
4681
|
+
# "my_sorted_set".
|
|
4682
|
+
>>> await client.zcount(
|
|
4683
|
+
... "my_sorted_set",
|
|
4684
|
+
... ScoreBoundary(5.0 , is_inclusive=true),
|
|
4685
|
+
... ScoreBoundary(10.0 , is_inclusive=false)
|
|
4686
|
+
... )
|
|
4276
4687
|
1 # Indicates that there is one ScoreBoundary with 5.0 < score <= 10.0 in the sorted set "my_sorted_set".
|
|
4277
4688
|
"""
|
|
4278
4689
|
score_min = (
|
|
4279
4690
|
min_score.value["score_arg"]
|
|
4280
|
-
if
|
|
4691
|
+
if isinstance(min_score, InfBound)
|
|
4281
4692
|
else min_score.value
|
|
4282
4693
|
)
|
|
4283
4694
|
score_max = (
|
|
4284
4695
|
max_score.value["score_arg"]
|
|
4285
|
-
if
|
|
4696
|
+
if isinstance(max_score, InfBound)
|
|
4286
4697
|
else max_score.value
|
|
4287
4698
|
)
|
|
4288
4699
|
return cast(
|
|
@@ -4300,7 +4711,7 @@ class CoreCommands(Protocol):
|
|
|
4300
4711
|
If `member` does not exist in the sorted set, it is added with `increment` as its score.
|
|
4301
4712
|
If `key` does not exist, a new sorted set is created with the specified member as its sole member.
|
|
4302
4713
|
|
|
4303
|
-
See https://valkey.io/commands/zincrby/ for more details.
|
|
4714
|
+
See [valkey.io](https://valkey.io/commands/zincrby/) for more details.
|
|
4304
4715
|
|
|
4305
4716
|
Args:
|
|
4306
4717
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4334,22 +4745,26 @@ class CoreCommands(Protocol):
|
|
|
4334
4745
|
If `count` is provided, up to `count` members with the highest scores are removed and returned.
|
|
4335
4746
|
Otherwise, only one member with the highest score is removed and returned.
|
|
4336
4747
|
|
|
4337
|
-
See https://valkey.io/commands/zpopmax for more details.
|
|
4748
|
+
See [valkey.io](https://valkey.io/commands/zpopmax) for more details.
|
|
4338
4749
|
|
|
4339
4750
|
Args:
|
|
4340
4751
|
key (TEncodable): The key of the sorted set.
|
|
4341
4752
|
count (Optional[int]): Specifies the quantity of members to pop. If not specified, pops one member.
|
|
4342
|
-
|
|
4753
|
+
If `count` is higher than the sorted set's cardinality, returns all members and their scores, ordered from
|
|
4754
|
+
highest to lowest.
|
|
4343
4755
|
|
|
4344
4756
|
Returns:
|
|
4345
|
-
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the highest score
|
|
4346
|
-
|
|
4757
|
+
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the highest score
|
|
4758
|
+
to the one with the lowest.
|
|
4759
|
+
|
|
4760
|
+
If `key` doesn't exist, it will be treated as an empty sorted set and the command returns an empty map.
|
|
4347
4761
|
|
|
4348
4762
|
Examples:
|
|
4349
4763
|
>>> await client.zpopmax("my_sorted_set")
|
|
4350
4764
|
{b'member1': 10.0} # Indicates that 'member1' with a score of 10.0 has been removed from the sorted set.
|
|
4351
4765
|
>>> 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
|
|
4766
|
+
{b'member2': 8.0, b'member3': 7.5} # Indicates that 'member2' with a score of 8.0 and 'member3' with a score
|
|
4767
|
+
# of 7.5 have been removed from the sorted set.
|
|
4353
4768
|
"""
|
|
4354
4769
|
return cast(
|
|
4355
4770
|
Mapping[bytes, float],
|
|
@@ -4366,13 +4781,14 @@ class CoreCommands(Protocol):
|
|
|
4366
4781
|
the order that they are given. Blocks the connection when there are no members to remove from any of the given
|
|
4367
4782
|
sorted sets.
|
|
4368
4783
|
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4784
|
+
Note:
|
|
4785
|
+
1. When in cluster mode, all keys must map to the same hash slot.
|
|
4786
|
+
2. `BZPOPMAX` is the blocking variant of `ZPOPMAX`.
|
|
4787
|
+
3. `BZPOPMAX` is a client blocking command, see
|
|
4788
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
4789
|
+
for more details and best practices.
|
|
4374
4790
|
|
|
4375
|
-
See https://valkey.io/commands/bzpopmax for more details.
|
|
4791
|
+
See [valkey.io](https://valkey.io/commands/bzpopmax) for more details.
|
|
4376
4792
|
|
|
4377
4793
|
Args:
|
|
4378
4794
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -4380,8 +4796,10 @@ class CoreCommands(Protocol):
|
|
|
4380
4796
|
A value of 0 will block indefinitely.
|
|
4381
4797
|
|
|
4382
4798
|
Returns:
|
|
4383
|
-
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4384
|
-
|
|
4799
|
+
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4800
|
+
itself, and the member score.
|
|
4801
|
+
|
|
4802
|
+
If no member could be popped and the `timeout` expired, returns None.
|
|
4385
4803
|
|
|
4386
4804
|
Examples:
|
|
4387
4805
|
>>> await client.zadd("my_sorted_set1", {"member1": 10.0, "member2": 5.0})
|
|
@@ -4402,22 +4820,25 @@ class CoreCommands(Protocol):
|
|
|
4402
4820
|
If `count` is provided, up to `count` members with the lowest scores are removed and returned.
|
|
4403
4821
|
Otherwise, only one member with the lowest score is removed and returned.
|
|
4404
4822
|
|
|
4405
|
-
See https://valkey.io/commands/zpopmin for more details.
|
|
4823
|
+
See [valkey.io](https://valkey.io/commands/zpopmin) for more details.
|
|
4406
4824
|
|
|
4407
4825
|
Args:
|
|
4408
4826
|
key (TEncodable): The key of the sorted set.
|
|
4409
4827
|
count (Optional[int]): Specifies the quantity of members to pop. If not specified, pops one member.
|
|
4410
|
-
|
|
4828
|
+
If `count` is higher than the sorted set's cardinality, returns all members and their scores.
|
|
4411
4829
|
|
|
4412
4830
|
Returns:
|
|
4413
|
-
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the lowest score
|
|
4414
|
-
|
|
4831
|
+
Mapping[bytes, float]: A map of the removed members and their scores, ordered from the one with the lowest score
|
|
4832
|
+
to the one with the highest.
|
|
4833
|
+
|
|
4834
|
+
If `key` doesn't exist, it will be treated as an empty sorted set and the command returns an empty map.
|
|
4415
4835
|
|
|
4416
4836
|
Examples:
|
|
4417
4837
|
>>> await client.zpopmin("my_sorted_set")
|
|
4418
4838
|
{b'member1': 5.0} # Indicates that 'member1' with a score of 5.0 has been removed from the sorted set.
|
|
4419
4839
|
>>> 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
|
|
4840
|
+
{b'member3': 7.5 , b'member2': 8.0} # Indicates that 'member3' with a score of 7.5 and 'member2' with a score
|
|
4841
|
+
# of 8.0 have been removed from the sorted set.
|
|
4421
4842
|
"""
|
|
4422
4843
|
args: List[TEncodable] = [key, str(count)] if count else [key]
|
|
4423
4844
|
return cast(
|
|
@@ -4433,13 +4854,14 @@ class CoreCommands(Protocol):
|
|
|
4433
4854
|
the order that they are given. Blocks the connection when there are no members to remove from any of the given
|
|
4434
4855
|
sorted sets.
|
|
4435
4856
|
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4857
|
+
Note:
|
|
4858
|
+
1. When in cluster mode, all keys must map to the same hash slot.
|
|
4859
|
+
2. `BZPOPMIN` is the blocking variant of `ZPOPMIN`.
|
|
4860
|
+
3. `BZPOPMIN` is a client blocking command, see
|
|
4861
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
4862
|
+
for more details and best practices.
|
|
4441
4863
|
|
|
4442
|
-
See https://valkey.io/commands/bzpopmin for more details.
|
|
4864
|
+
See [valkey.io](https://valkey.io/commands/bzpopmin) for more details.
|
|
4443
4865
|
|
|
4444
4866
|
Args:
|
|
4445
4867
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -4447,8 +4869,10 @@ class CoreCommands(Protocol):
|
|
|
4447
4869
|
A value of 0 will block indefinitely.
|
|
4448
4870
|
|
|
4449
4871
|
Returns:
|
|
4450
|
-
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4451
|
-
|
|
4872
|
+
Optional[List[Union[bytes, float]]]: An array containing the key where the member was popped out, the member
|
|
4873
|
+
itself, and the member score.
|
|
4874
|
+
|
|
4875
|
+
If no member could be popped and the `timeout` expired, returns None.
|
|
4452
4876
|
|
|
4453
4877
|
Examples:
|
|
4454
4878
|
>>> await client.zadd("my_sorted_set1", {"member1": 10.0, "member2": 5.0})
|
|
@@ -4473,27 +4897,32 @@ class CoreCommands(Protocol):
|
|
|
4473
4897
|
|
|
4474
4898
|
ZRANGE can perform different types of range queries: by index (rank), by the score, or by lexicographical order.
|
|
4475
4899
|
|
|
4476
|
-
See https://valkey.io/commands/zrange/ for more details.
|
|
4900
|
+
See [valkey.io](https://valkey.io/commands/zrange/) for more details.
|
|
4477
4901
|
|
|
4478
4902
|
To get the elements with their scores, see zrange_withscores.
|
|
4479
4903
|
|
|
4480
4904
|
Args:
|
|
4481
4905
|
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
|
-
|
|
4906
|
+
range_query (Union[RangeByIndex, RangeByLex, RangeByScore]): The range query object representing the type of range
|
|
4907
|
+
query to perform.
|
|
4908
|
+
|
|
4909
|
+
- For range queries by index (rank), use RangeByIndex.
|
|
4910
|
+
- For range queries by lexicographical order, use RangeByLex.
|
|
4911
|
+
- For range queries by score, use RangeByScore.
|
|
4912
|
+
|
|
4486
4913
|
reverse (bool): If True, reverses the sorted set, with index 0 as the element with the highest score.
|
|
4487
4914
|
|
|
4488
4915
|
Returns:
|
|
4489
4916
|
List[bytes]: A list of elements within the specified range.
|
|
4917
|
+
|
|
4490
4918
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns an empty array.
|
|
4491
4919
|
|
|
4492
4920
|
Examples:
|
|
4493
4921
|
>>> await client.zrange("my_sorted_set", RangeByIndex(0, -1))
|
|
4494
4922
|
[b'member1', b'member2', b'member3'] # Returns all members in ascending order.
|
|
4495
4923
|
>>> 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
|
|
4924
|
+
[b'member2', b'member3'] # Returns members with scores within the range of negative infinity to 3, in
|
|
4925
|
+
# ascending order.
|
|
4497
4926
|
"""
|
|
4498
4927
|
args = _create_zrange_args(key, range_query, reverse, with_scores=False)
|
|
4499
4928
|
|
|
@@ -4509,24 +4938,29 @@ class CoreCommands(Protocol):
|
|
|
4509
4938
|
Returns the specified range of elements with their scores in the sorted set stored at `key`.
|
|
4510
4939
|
Similar to ZRANGE but with a WITHSCORE flag.
|
|
4511
4940
|
|
|
4512
|
-
See https://valkey.io/commands/zrange/ for more details.
|
|
4941
|
+
See [valkey.io](https://valkey.io/commands/zrange/) for more details.
|
|
4513
4942
|
|
|
4514
4943
|
Args:
|
|
4515
4944
|
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
|
-
|
|
4945
|
+
range_query (Union[RangeByIndex, RangeByScore]): The range query object representing the type of range query to
|
|
4946
|
+
perform.
|
|
4947
|
+
|
|
4948
|
+
- For range queries by index (rank), use RangeByIndex.
|
|
4949
|
+
- For range queries by score, use RangeByScore.
|
|
4950
|
+
|
|
4519
4951
|
reverse (bool): If True, reverses the sorted set, with index 0 as the element with the highest score.
|
|
4520
4952
|
|
|
4521
4953
|
Returns:
|
|
4522
4954
|
Mapping[bytes , float]: A map of elements and their scores within the specified range.
|
|
4955
|
+
|
|
4523
4956
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns an empty map.
|
|
4524
4957
|
|
|
4525
4958
|
Examples:
|
|
4526
4959
|
>>> await client.zrange_withscores("my_sorted_set", RangeByScore(ScoreBoundary(10), ScoreBoundary(20)))
|
|
4527
4960
|
{b'member1': 10.5, b'member2': 15.2} # Returns members with scores between 10 and 20 with their scores.
|
|
4528
4961
|
>>> 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
|
|
4962
|
+
{b'member4': -2.0, b'member7': 1.5} # Returns members with with scores within the range of negative infinity
|
|
4963
|
+
# to 3, with their scores.
|
|
4530
4964
|
"""
|
|
4531
4965
|
args = _create_zrange_args(key, range_query, reverse, with_scores=True)
|
|
4532
4966
|
|
|
@@ -4548,7 +4982,7 @@ class CoreCommands(Protocol):
|
|
|
4548
4982
|
ZRANGESTORE can perform different types of range queries: by index (rank), by the score, or by lexicographical
|
|
4549
4983
|
order.
|
|
4550
4984
|
|
|
4551
|
-
See https://valkey.io/commands/zrangestore for more details.
|
|
4985
|
+
See [valkey.io](https://valkey.io/commands/zrangestore) for more details.
|
|
4552
4986
|
|
|
4553
4987
|
Note:
|
|
4554
4988
|
When in Cluster mode, `source` and `destination` must map to the same hash slot.
|
|
@@ -4556,10 +4990,13 @@ class CoreCommands(Protocol):
|
|
|
4556
4990
|
Args:
|
|
4557
4991
|
destination (TEncodable): The key for the destination sorted set.
|
|
4558
4992
|
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
|
-
|
|
4993
|
+
range_query (Union[RangeByIndex, RangeByLex, RangeByScore]): The range query object representing the type of range
|
|
4994
|
+
query to perform.
|
|
4995
|
+
|
|
4996
|
+
- For range queries by index (rank), use RangeByIndex.
|
|
4997
|
+
- For range queries by lexicographical order, use RangeByLex.
|
|
4998
|
+
- For range queries by score, use RangeByScore.
|
|
4999
|
+
|
|
4563
5000
|
reverse (bool): If True, reverses the sorted set, with index 0 as the element with the highest score.
|
|
4564
5001
|
|
|
4565
5002
|
Returns:
|
|
@@ -4567,9 +5004,11 @@ class CoreCommands(Protocol):
|
|
|
4567
5004
|
|
|
4568
5005
|
Examples:
|
|
4569
5006
|
>>> 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
|
|
5007
|
+
3 # The 3 members with the highest scores from "my_sorted_set" were stored in the sorted set at
|
|
5008
|
+
# "destination_key".
|
|
4571
5009
|
>>> 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
|
|
5010
|
+
2 # The 2 members with scores between negative infinity and 3 (inclusive) from "my_sorted_set" were stored in
|
|
5011
|
+
# the sorted set at "destination_key".
|
|
4573
5012
|
"""
|
|
4574
5013
|
args = _create_zrange_args(source, range_query, reverse, False, destination)
|
|
4575
5014
|
|
|
@@ -4583,7 +5022,7 @@ class CoreCommands(Protocol):
|
|
|
4583
5022
|
"""
|
|
4584
5023
|
Returns the rank of `member` in the sorted set stored at `key`, with scores ordered from low to high.
|
|
4585
5024
|
|
|
4586
|
-
See https://valkey.io/commands/zrank for more details.
|
|
5025
|
+
See [valkey.io](https://valkey.io/commands/zrank) for more details.
|
|
4587
5026
|
|
|
4588
5027
|
To get the rank of `member` with its score, see `zrank_withscore`.
|
|
4589
5028
|
|
|
@@ -4593,9 +5032,10 @@ class CoreCommands(Protocol):
|
|
|
4593
5032
|
|
|
4594
5033
|
Returns:
|
|
4595
5034
|
Optional[int]: The rank of `member` in the sorted set.
|
|
5035
|
+
|
|
4596
5036
|
If `key` doesn't exist, or if `member` is not present in the set, None will be returned.
|
|
4597
5037
|
|
|
4598
|
-
|
|
5038
|
+
Examples:
|
|
4599
5039
|
>>> await client.zrank("my_sorted_set", "member2")
|
|
4600
5040
|
1 # Indicates that "member2" has the second-lowest score in the sorted set "my_sorted_set".
|
|
4601
5041
|
>>> await client.zrank("my_sorted_set", "non_existing_member")
|
|
@@ -4611,9 +5051,10 @@ class CoreCommands(Protocol):
|
|
|
4611
5051
|
member: TEncodable,
|
|
4612
5052
|
) -> Optional[List[Union[int, float]]]:
|
|
4613
5053
|
"""
|
|
4614
|
-
Returns the rank of `member` in the sorted set stored at `key` with its score, where scores are ordered from the
|
|
5054
|
+
Returns the rank of `member` in the sorted set stored at `key` with its score, where scores are ordered from the
|
|
5055
|
+
lowest to highest.
|
|
4615
5056
|
|
|
4616
|
-
See https://valkey.io/commands/zrank for more details.
|
|
5057
|
+
See [valkey.io](https://valkey.io/commands/zrank) for more details.
|
|
4617
5058
|
|
|
4618
5059
|
Args:
|
|
4619
5060
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4621,11 +5062,13 @@ class CoreCommands(Protocol):
|
|
|
4621
5062
|
|
|
4622
5063
|
Returns:
|
|
4623
5064
|
Optional[List[Union[int, float]]]: A list containing the rank and score of `member` in the sorted set.
|
|
5065
|
+
|
|
4624
5066
|
If `key` doesn't exist, or if `member` is not present in the set, None will be returned.
|
|
4625
5067
|
|
|
4626
5068
|
Examples:
|
|
4627
5069
|
>>> 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
|
|
5070
|
+
[1 , 6.0] # Indicates that "member2" with score 6.0 has the second-lowest score in the sorted set
|
|
5071
|
+
# "my_sorted_set".
|
|
4629
5072
|
>>> await client.zrank_withscore("my_sorted_set", "non_existing_member")
|
|
4630
5073
|
None # Indicates that "non_existing_member" is not present in the sorted set "my_sorted_set".
|
|
4631
5074
|
|
|
@@ -4643,7 +5086,7 @@ class CoreCommands(Protocol):
|
|
|
4643
5086
|
|
|
4644
5087
|
To get the rank of `member` with its score, see `zrevrank_withscore`.
|
|
4645
5088
|
|
|
4646
|
-
See https://valkey.io/commands/zrevrank for more details.
|
|
5089
|
+
See [valkey.io](https://valkey.io/commands/zrevrank) for more details.
|
|
4647
5090
|
|
|
4648
5091
|
Args:
|
|
4649
5092
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4651,7 +5094,8 @@ class CoreCommands(Protocol):
|
|
|
4651
5094
|
|
|
4652
5095
|
Returns:
|
|
4653
5096
|
Optional[int]: The rank of `member` in the sorted set, where ranks are ordered from high to low based on scores.
|
|
4654
|
-
|
|
5097
|
+
|
|
5098
|
+
If `key` doesn't exist, or if `member` is not present in the set, `None` will be returned.
|
|
4655
5099
|
|
|
4656
5100
|
Examples:
|
|
4657
5101
|
>>> await client.zadd("my_sorted_set", {"member1": 10.5, "member2": 8.2, "member3": 9.6})
|
|
@@ -4670,7 +5114,7 @@ class CoreCommands(Protocol):
|
|
|
4670
5114
|
Returns the rank of `member` in the sorted set stored at `key` with its score, where scores are ordered from the
|
|
4671
5115
|
highest to lowest, starting from `0`.
|
|
4672
5116
|
|
|
4673
|
-
See https://valkey.io/commands/zrevrank for more details.
|
|
5117
|
+
See [valkey.io](https://valkey.io/commands/zrevrank) for more details.
|
|
4674
5118
|
|
|
4675
5119
|
Args:
|
|
4676
5120
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4678,8 +5122,9 @@ class CoreCommands(Protocol):
|
|
|
4678
5122
|
|
|
4679
5123
|
Returns:
|
|
4680
5124
|
Optional[List[Union[int, float]]]: A list containing the rank (as `int`) and score (as `float`) of `member`
|
|
4681
|
-
|
|
4682
|
-
|
|
5125
|
+
in the sorted set, where ranks are ordered from high to low based on scores.
|
|
5126
|
+
|
|
5127
|
+
If `key` doesn't exist, or if `member` is not present in the set, `None` will be returned.
|
|
4683
5128
|
|
|
4684
5129
|
Examples:
|
|
4685
5130
|
>>> await client.zadd("my_sorted_set", {"member1": 10.5, "member2": 8.2, "member3": 9.6})
|
|
@@ -4704,7 +5149,7 @@ class CoreCommands(Protocol):
|
|
|
4704
5149
|
Removes the specified members from the sorted set stored at `key`.
|
|
4705
5150
|
Specified members that are not a member of this set are ignored.
|
|
4706
5151
|
|
|
4707
|
-
See https://valkey.io/commands/zrem/ for more details.
|
|
5152
|
+
See [valkey.io](https://valkey.io/commands/zrem/) for more details.
|
|
4708
5153
|
|
|
4709
5154
|
Args:
|
|
4710
5155
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4712,6 +5157,7 @@ class CoreCommands(Protocol):
|
|
|
4712
5157
|
|
|
4713
5158
|
Returns:
|
|
4714
5159
|
int: The number of members that were removed from the sorted set, not including non-existing members.
|
|
5160
|
+
|
|
4715
5161
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
4716
5162
|
|
|
4717
5163
|
Examples:
|
|
@@ -4734,7 +5180,7 @@ class CoreCommands(Protocol):
|
|
|
4734
5180
|
"""
|
|
4735
5181
|
Removes all elements in the sorted set stored at `key` with a score between `min_score` and `max_score`.
|
|
4736
5182
|
|
|
4737
|
-
See https://valkey.io/commands/zremrangebyscore/ for more details.
|
|
5183
|
+
See [valkey.io](https://valkey.io/commands/zremrangebyscore/) for more details.
|
|
4738
5184
|
|
|
4739
5185
|
Args:
|
|
4740
5186
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4746,23 +5192,30 @@ class CoreCommands(Protocol):
|
|
|
4746
5192
|
or ScoreBoundary representing a specific score and inclusivity.
|
|
4747
5193
|
Returns:
|
|
4748
5194
|
int: The number of members that were removed from the sorted set.
|
|
5195
|
+
|
|
4749
5196
|
If `key` does not exist, it is treated as an empty sorted set, and the command returns 0.
|
|
5197
|
+
|
|
4750
5198
|
If `min_score` is greater than `max_score`, 0 is returned.
|
|
4751
5199
|
|
|
4752
5200
|
Examples:
|
|
4753
5201
|
>>> 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
|
-
|
|
5202
|
+
2 # Indicates that 2 members with scores between 5.0 (not exclusive) and +inf have been removed from the
|
|
5203
|
+
# sorted set "my_sorted_set".
|
|
5204
|
+
>>> await client.zremrangebyscore(
|
|
5205
|
+
... "non_existing_sorted_set",
|
|
5206
|
+
... ScoreBoundary(5.0 , is_inclusive=true),
|
|
5207
|
+
... ScoreBoundary(10.0 , is_inclusive=false)
|
|
5208
|
+
... )
|
|
4756
5209
|
0 # Indicates that no members were removed as the sorted set "non_existing_sorted_set" does not exist.
|
|
4757
5210
|
"""
|
|
4758
5211
|
score_min = (
|
|
4759
5212
|
min_score.value["score_arg"]
|
|
4760
|
-
if
|
|
5213
|
+
if isinstance(min_score, InfBound)
|
|
4761
5214
|
else min_score.value
|
|
4762
5215
|
)
|
|
4763
5216
|
score_max = (
|
|
4764
5217
|
max_score.value["score_arg"]
|
|
4765
|
-
if
|
|
5218
|
+
if isinstance(max_score, InfBound)
|
|
4766
5219
|
else max_score.value
|
|
4767
5220
|
)
|
|
4768
5221
|
|
|
@@ -4783,7 +5236,7 @@ class CoreCommands(Protocol):
|
|
|
4783
5236
|
Removes all elements in the sorted set stored at `key` with a lexicographical order between `min_lex` and
|
|
4784
5237
|
`max_lex`.
|
|
4785
5238
|
|
|
4786
|
-
See https://valkey.io/commands/zremrangebylex/ for more details.
|
|
5239
|
+
See [valkey.io](https://valkey.io/commands/zremrangebylex/) for more details.
|
|
4787
5240
|
|
|
4788
5241
|
Args:
|
|
4789
5242
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4796,20 +5249,23 @@ class CoreCommands(Protocol):
|
|
|
4796
5249
|
|
|
4797
5250
|
Returns:
|
|
4798
5251
|
int: The number of members that were removed from the sorted set.
|
|
4799
|
-
|
|
4800
|
-
|
|
5252
|
+
|
|
5253
|
+
If `key` does not exist, it is treated as an empty sorted set, and the command returns `0`.
|
|
5254
|
+
|
|
5255
|
+
If `min_lex` is greater than `max_lex`, `0` is returned.
|
|
4801
5256
|
|
|
4802
5257
|
Examples:
|
|
4803
5258
|
>>> 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),
|
|
5259
|
+
4 # Indicates that 4 members, with lexicographical values ranging from "a" (exclusive) to "e" (inclusive),
|
|
5260
|
+
# have been removed from "my_sorted_set".
|
|
4805
5261
|
>>> await client.zremrangebylex("non_existing_sorted_set", InfBound.NEG_INF, LexBoundary("e"))
|
|
4806
5262
|
0 # Indicates that no members were removed as the sorted set "non_existing_sorted_set" does not exist.
|
|
4807
5263
|
"""
|
|
4808
5264
|
min_lex_arg = (
|
|
4809
|
-
min_lex.value["lex_arg"] if
|
|
5265
|
+
min_lex.value["lex_arg"] if isinstance(min_lex, InfBound) else min_lex.value
|
|
4810
5266
|
)
|
|
4811
5267
|
max_lex_arg = (
|
|
4812
|
-
max_lex.value["lex_arg"] if
|
|
5268
|
+
max_lex.value["lex_arg"] if isinstance(max_lex, InfBound) else max_lex.value
|
|
4813
5269
|
)
|
|
4814
5270
|
|
|
4815
5271
|
return cast(
|
|
@@ -4830,7 +5286,7 @@ class CoreCommands(Protocol):
|
|
|
4830
5286
|
Both `start` and `end` are zero-based indexes with 0 being the element with the lowest score.
|
|
4831
5287
|
These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score.
|
|
4832
5288
|
|
|
4833
|
-
See https://valkey.io/commands/zremrangebyrank/ for more details.
|
|
5289
|
+
See [valkey.io](https://valkey.io/commands/zremrangebyrank/) for more details.
|
|
4834
5290
|
|
|
4835
5291
|
Args:
|
|
4836
5292
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4839,13 +5295,17 @@ class CoreCommands(Protocol):
|
|
|
4839
5295
|
|
|
4840
5296
|
Returns:
|
|
4841
5297
|
int: The number of elements that were removed.
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
5298
|
+
|
|
5299
|
+
If `start` exceeds the end of the sorted set, or if `start` is greater than `end`, `0` is returned.
|
|
5300
|
+
|
|
5301
|
+
If `end` exceeds the actual end of the sorted set, the range will stop at the actual end of the sorted set.
|
|
5302
|
+
|
|
5303
|
+
If `key` does not exist, `0` is returned.
|
|
4845
5304
|
|
|
4846
5305
|
Examples:
|
|
4847
5306
|
>>> 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
|
|
5307
|
+
5 # Indicates that 5 elements, with ranks ranging from 0 to 4 (inclusive), have been removed from
|
|
5308
|
+
# "my_sorted_set".
|
|
4849
5309
|
>>> await client.zremrangebyrank("my_sorted_set", 0, 4)
|
|
4850
5310
|
0 # Indicates that nothing was removed.
|
|
4851
5311
|
"""
|
|
@@ -4863,9 +5323,10 @@ class CoreCommands(Protocol):
|
|
|
4863
5323
|
max_lex: Union[InfBound, LexBoundary],
|
|
4864
5324
|
) -> int:
|
|
4865
5325
|
"""
|
|
4866
|
-
Returns the number of members in the sorted set stored at `key` with lexicographical values between `min_lex` and
|
|
5326
|
+
Returns the number of members in the sorted set stored at `key` with lexicographical values between `min_lex` and
|
|
5327
|
+
`max_lex`.
|
|
4867
5328
|
|
|
4868
|
-
See https://valkey.io/commands/zlexcount/ for more details.
|
|
5329
|
+
See [valkey.io](https://valkey.io/commands/zlexcount/) for more details.
|
|
4869
5330
|
|
|
4870
5331
|
Args:
|
|
4871
5332
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4878,20 +5339,28 @@ class CoreCommands(Protocol):
|
|
|
4878
5339
|
|
|
4879
5340
|
Returns:
|
|
4880
5341
|
int: The number of members in the specified lexicographical range.
|
|
4881
|
-
|
|
4882
|
-
|
|
5342
|
+
|
|
5343
|
+
If `key` does not exist, it is treated as an empty sorted set, and the command returns `0`.
|
|
5344
|
+
|
|
5345
|
+
If `max_lex < min_lex`, `0` is returned.
|
|
4883
5346
|
|
|
4884
5347
|
Examples:
|
|
4885
5348
|
>>> 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
|
-
|
|
5349
|
+
2 # Indicates that there are 2 members with lexicographical values between "c" (inclusive) and positive
|
|
5350
|
+
# infinity in the sorted set "my_sorted_set".
|
|
5351
|
+
>>> await client.zlexcount(
|
|
5352
|
+
... "my_sorted_set",
|
|
5353
|
+
... LexBoundary("c" , is_inclusive=True),
|
|
5354
|
+
... LexBoundary("k" , is_inclusive=False)
|
|
5355
|
+
... )
|
|
5356
|
+
1 # Indicates that there is one member with LexBoundary "c" <= lexicographical value < "k" in the sorted set
|
|
5357
|
+
# "my_sorted_set".
|
|
4889
5358
|
"""
|
|
4890
5359
|
min_lex_arg = (
|
|
4891
|
-
min_lex.value["lex_arg"] if
|
|
5360
|
+
min_lex.value["lex_arg"] if isinstance(min_lex, InfBound) else min_lex.value
|
|
4892
5361
|
)
|
|
4893
5362
|
max_lex_arg = (
|
|
4894
|
-
max_lex.value["lex_arg"] if
|
|
5363
|
+
max_lex.value["lex_arg"] if isinstance(max_lex, InfBound) else max_lex.value
|
|
4895
5364
|
)
|
|
4896
5365
|
|
|
4897
5366
|
return cast(
|
|
@@ -4905,7 +5374,7 @@ class CoreCommands(Protocol):
|
|
|
4905
5374
|
"""
|
|
4906
5375
|
Returns the score of `member` in the sorted set stored at `key`.
|
|
4907
5376
|
|
|
4908
|
-
See https://valkey.io/commands/zscore/ for more details.
|
|
5377
|
+
See [valkey.io](https://valkey.io/commands/zscore/) for more details.
|
|
4909
5378
|
|
|
4910
5379
|
Args:
|
|
4911
5380
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4913,7 +5382,9 @@ class CoreCommands(Protocol):
|
|
|
4913
5382
|
|
|
4914
5383
|
Returns:
|
|
4915
5384
|
Optional[float]: The score of the member.
|
|
5385
|
+
|
|
4916
5386
|
If `member` does not exist in the sorted set, None is returned.
|
|
5387
|
+
|
|
4917
5388
|
If `key` does not exist, None is returned.
|
|
4918
5389
|
|
|
4919
5390
|
Examples:
|
|
@@ -4935,7 +5406,7 @@ class CoreCommands(Protocol):
|
|
|
4935
5406
|
"""
|
|
4936
5407
|
Returns the scores associated with the specified `members` in the sorted set stored at `key`.
|
|
4937
5408
|
|
|
4938
|
-
See https://valkey.io/commands/zmscore for more details.
|
|
5409
|
+
See [valkey.io](https://valkey.io/commands/zmscore) for more details.
|
|
4939
5410
|
|
|
4940
5411
|
Args:
|
|
4941
5412
|
key (TEncodable): The key of the sorted set.
|
|
@@ -4943,7 +5414,8 @@ class CoreCommands(Protocol):
|
|
|
4943
5414
|
|
|
4944
5415
|
Returns:
|
|
4945
5416
|
List[Optional[float]]: A list of scores corresponding to `members`.
|
|
4946
|
-
|
|
5417
|
+
|
|
5418
|
+
If a member does not exist in the sorted set, the corresponding value in the list will be None.
|
|
4947
5419
|
|
|
4948
5420
|
Examples:
|
|
4949
5421
|
>>> await client.zmscore("my_sorted_set", ["one", "non_existent_member", "three"])
|
|
@@ -4959,17 +5431,19 @@ class CoreCommands(Protocol):
|
|
|
4959
5431
|
Returns the difference between the first sorted set and all the successive sorted sets.
|
|
4960
5432
|
To get the elements with their scores, see `zdiff_withscores`.
|
|
4961
5433
|
|
|
4962
|
-
|
|
5434
|
+
Note:
|
|
5435
|
+
When in Cluster mode, all keys must map to the same hash slot.
|
|
4963
5436
|
|
|
4964
|
-
See https://valkey.io/commands/zdiff for more details.
|
|
5437
|
+
See [valkey.io](https://valkey.io/commands/zdiff) for more details.
|
|
4965
5438
|
|
|
4966
5439
|
Args:
|
|
4967
5440
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
4968
5441
|
|
|
4969
5442
|
Returns:
|
|
4970
5443
|
List[bytes]: A list of elements representing the difference between the sorted sets.
|
|
4971
|
-
|
|
4972
|
-
|
|
5444
|
+
|
|
5445
|
+
If the first key does not exist, it is treated as an empty sorted set, and the command returns an
|
|
5446
|
+
empty list.
|
|
4973
5447
|
|
|
4974
5448
|
Examples:
|
|
4975
5449
|
>>> await client.zadd("sorted_set1", {"element1":1.0, "element2": 2.0, "element3": 3.0})
|
|
@@ -4988,18 +5462,21 @@ class CoreCommands(Protocol):
|
|
|
4988
5462
|
async def zdiff_withscores(self, keys: List[TEncodable]) -> Mapping[bytes, float]:
|
|
4989
5463
|
"""
|
|
4990
5464
|
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
5465
|
|
|
4993
|
-
|
|
5466
|
+
Note:
|
|
5467
|
+
When in Cluster mode, all keys must map to the same hash slot.
|
|
5468
|
+
|
|
5469
|
+
See [valkey.io](https://valkey.io/commands/zdiff) for more details.
|
|
4994
5470
|
|
|
4995
5471
|
Args:
|
|
4996
5472
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
4997
5473
|
|
|
4998
5474
|
Returns:
|
|
4999
5475
|
Mapping[bytes, float]: A mapping of elements and their scores representing the difference between the sorted
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5476
|
+
sets.
|
|
5477
|
+
|
|
5478
|
+
If the first `key` does not exist, it is treated as an empty sorted set, and the command returns an
|
|
5479
|
+
empty list.
|
|
5003
5480
|
|
|
5004
5481
|
Examples:
|
|
5005
5482
|
>>> await client.zadd("sorted_set1", {"element1":1.0, "element2": 2.0, "element3": 3.0})
|
|
@@ -5020,11 +5497,12 @@ class CoreCommands(Protocol):
|
|
|
5020
5497
|
Calculates the difference between the first sorted set and all the successive sorted sets at `keys` and stores
|
|
5021
5498
|
the difference as a sorted set to `destination`, overwriting it if it already exists. Non-existent keys are
|
|
5022
5499
|
treated as empty sets.
|
|
5023
|
-
See https://valkey.io/commands/zdiffstore for more details.
|
|
5024
5500
|
|
|
5025
5501
|
Note:
|
|
5026
5502
|
When in Cluster mode, all keys in `keys` and `destination` must map to the same hash slot.
|
|
5027
5503
|
|
|
5504
|
+
See [valkey.io](https://valkey.io/commands/zdiffstore) for more details.
|
|
5505
|
+
|
|
5028
5506
|
Args:
|
|
5029
5507
|
destination (TEncodable): The key for the resulting sorted set.
|
|
5030
5508
|
keys (List[TEncodable]): The keys of the sorted sets to compare.
|
|
@@ -5058,9 +5536,10 @@ class CoreCommands(Protocol):
|
|
|
5058
5536
|
To get the scores as well, see `zinter_withscores`.
|
|
5059
5537
|
To store the result in a key as a sorted set, see `zinterstore`.
|
|
5060
5538
|
|
|
5061
|
-
|
|
5539
|
+
Note:
|
|
5540
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5062
5541
|
|
|
5063
|
-
See https://valkey.io/commands/zinter/ for more details.
|
|
5542
|
+
See [valkey.io](https://valkey.io/commands/zinter/) for more details.
|
|
5064
5543
|
|
|
5065
5544
|
Args:
|
|
5066
5545
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -5087,18 +5566,22 @@ class CoreCommands(Protocol):
|
|
|
5087
5566
|
aggregation_type: Optional[AggregationType] = None,
|
|
5088
5567
|
) -> Mapping[bytes, float]:
|
|
5089
5568
|
"""
|
|
5090
|
-
Computes the intersection of sorted sets given by the specified `keys` and returns a sorted set of intersecting
|
|
5569
|
+
Computes the intersection of sorted sets given by the specified `keys` and returns a sorted set of intersecting
|
|
5570
|
+
elements with scores.
|
|
5091
5571
|
To get the elements only, see `zinter`.
|
|
5092
5572
|
To store the result in a key as a sorted set, see `zinterstore`.
|
|
5093
5573
|
|
|
5094
|
-
|
|
5574
|
+
Note:
|
|
5575
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5095
5576
|
|
|
5096
|
-
See https://valkey.io/commands/zinter/ for more details.
|
|
5577
|
+
See [valkey.io](https://valkey.io/commands/zinter/) for more details.
|
|
5097
5578
|
|
|
5098
5579
|
Args:
|
|
5099
5580
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5100
|
-
|
|
5101
|
-
List[
|
|
5581
|
+
|
|
5582
|
+
- List[TEncodable] - for keys only.
|
|
5583
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5584
|
+
|
|
5102
5585
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5103
5586
|
when combining the scores of elements. See `AggregationType`.
|
|
5104
5587
|
|
|
@@ -5131,15 +5614,18 @@ class CoreCommands(Protocol):
|
|
|
5131
5614
|
If `destination` already exists, it is overwritten. Otherwise, a new sorted set will be created.
|
|
5132
5615
|
To get the result directly, see `zinter_withscores`.
|
|
5133
5616
|
|
|
5134
|
-
|
|
5617
|
+
Note:
|
|
5618
|
+
When in cluster mode, `destination` and all keys in `keys` must map to the same hash slot.
|
|
5135
5619
|
|
|
5136
|
-
See https://valkey.io/commands/zinterstore/ for more details.
|
|
5620
|
+
See [valkey.io](https://valkey.io/commands/zinterstore/) for more details.
|
|
5137
5621
|
|
|
5138
5622
|
Args:
|
|
5139
5623
|
destination (TEncodable): The key of the destination sorted set.
|
|
5140
5624
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5141
|
-
|
|
5142
|
-
List[
|
|
5625
|
+
|
|
5626
|
+
- List[TEncodable] - for keys only.
|
|
5627
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5628
|
+
|
|
5143
5629
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5144
5630
|
when combining the scores of elements. See `AggregationType`.
|
|
5145
5631
|
|
|
@@ -5154,7 +5640,8 @@ class CoreCommands(Protocol):
|
|
|
5154
5640
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5155
5641
|
{b'member1': 20} # "member1" is now stored in "my_sorted_set" with score of 20.
|
|
5156
5642
|
>>> 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
|
|
5643
|
+
1 # Indicates that the sorted set "my_sorted_set" contains one element, and its score is the maximum score
|
|
5644
|
+
# between the sets.
|
|
5158
5645
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5159
5646
|
{b'member1': 10.5} # "member1" is now stored in "my_sorted_set" with score of 10.5.
|
|
5160
5647
|
"""
|
|
@@ -5173,9 +5660,10 @@ class CoreCommands(Protocol):
|
|
|
5173
5660
|
To get the scores as well, see `zunion_withscores`.
|
|
5174
5661
|
To store the result in a key as a sorted set, see `zunionstore`.
|
|
5175
5662
|
|
|
5176
|
-
|
|
5663
|
+
Note:
|
|
5664
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5177
5665
|
|
|
5178
|
-
See https://valkey.io/commands/zunion/ for more details.
|
|
5666
|
+
See [valkey.io](https://valkey.io/commands/zunion/) for more details.
|
|
5179
5667
|
|
|
5180
5668
|
Args:
|
|
5181
5669
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -5206,14 +5694,17 @@ class CoreCommands(Protocol):
|
|
|
5206
5694
|
To get the elements only, see `zunion`.
|
|
5207
5695
|
To store the result in a key as a sorted set, see `zunionstore`.
|
|
5208
5696
|
|
|
5209
|
-
|
|
5697
|
+
Note:
|
|
5698
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
5210
5699
|
|
|
5211
|
-
See https://valkey.io/commands/zunion/ for more details.
|
|
5700
|
+
See [valkey.io](https://valkey.io/commands/zunion/) for more details.
|
|
5212
5701
|
|
|
5213
5702
|
Args:
|
|
5214
5703
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5215
|
-
|
|
5216
|
-
List[
|
|
5704
|
+
|
|
5705
|
+
- List[TEncodable] - for keys only.
|
|
5706
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5707
|
+
|
|
5217
5708
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5218
5709
|
when combining the scores of elements. See `AggregationType`.
|
|
5219
5710
|
|
|
@@ -5246,15 +5737,18 @@ class CoreCommands(Protocol):
|
|
|
5246
5737
|
If `destination` already exists, it is overwritten. Otherwise, a new sorted set will be created.
|
|
5247
5738
|
To get the result directly, see `zunion_withscores`.
|
|
5248
5739
|
|
|
5249
|
-
|
|
5740
|
+
Note:
|
|
5741
|
+
When in cluster mode, `destination` and all keys in `keys` must map to the same hash slot.
|
|
5250
5742
|
|
|
5251
|
-
See https://valkey.io/commands/zunionstore/ for more details.
|
|
5743
|
+
See [valkey.io](https://valkey.io/commands/zunionstore/) for more details.
|
|
5252
5744
|
|
|
5253
5745
|
Args:
|
|
5254
5746
|
destination (TEncodable): The key of the destination sorted set.
|
|
5255
5747
|
keys (Union[List[TEncodable], List[Tuple[TEncodable, float]]]): The keys of the sorted sets with possible formats:
|
|
5256
|
-
|
|
5257
|
-
List[
|
|
5748
|
+
|
|
5749
|
+
- List[TEncodable] - for keys only.
|
|
5750
|
+
- List[Tuple[TEncodable, float]] - for weighted keys with score multipliers.
|
|
5751
|
+
|
|
5258
5752
|
aggregation_type (Optional[AggregationType]): Specifies the aggregation strategy to apply
|
|
5259
5753
|
when combining the scores of elements. See `AggregationType`.
|
|
5260
5754
|
|
|
@@ -5269,7 +5763,8 @@ class CoreCommands(Protocol):
|
|
|
5269
5763
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5270
5764
|
{b'member1': 20, b'member2': 8.2}
|
|
5271
5765
|
>>> 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
|
|
5766
|
+
2 # Indicates that the sorted set "my_sorted_set" contains two elements, and each score is the maximum score
|
|
5767
|
+
# between the sets.
|
|
5273
5768
|
>>> await client.zrange_withscores("my_sorted_set", RangeByIndex(0, -1))
|
|
5274
5769
|
{b'member1': 10.5, b'member2': 8.2}
|
|
5275
5770
|
"""
|
|
@@ -5283,14 +5778,15 @@ class CoreCommands(Protocol):
|
|
|
5283
5778
|
"""
|
|
5284
5779
|
Returns a random member from the sorted set stored at 'key'.
|
|
5285
5780
|
|
|
5286
|
-
See https://valkey.io/commands/zrandmember for more details.
|
|
5781
|
+
See [valkey.io](https://valkey.io/commands/zrandmember) for more details.
|
|
5287
5782
|
|
|
5288
5783
|
Args:
|
|
5289
5784
|
key (TEncodable): The key of the sorted set.
|
|
5290
5785
|
|
|
5291
5786
|
Returns:
|
|
5292
5787
|
Optional[bytes]: A random member from the sorted set.
|
|
5293
|
-
|
|
5788
|
+
|
|
5789
|
+
If the sorted set does not exist or is empty, the response will be None.
|
|
5294
5790
|
|
|
5295
5791
|
Examples:
|
|
5296
5792
|
>>> await client.zadd("my_sorted_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -5299,7 +5795,6 @@ class CoreCommands(Protocol):
|
|
|
5299
5795
|
>>> await client.zrandmember("non_existing_sorted_set")
|
|
5300
5796
|
None # "non_existing_sorted_set" is not an existing key, so None was returned.
|
|
5301
5797
|
"""
|
|
5302
|
-
args: List[TEncodable] = [key]
|
|
5303
5798
|
return cast(
|
|
5304
5799
|
Optional[bytes],
|
|
5305
5800
|
await self._execute_command(RequestType.ZRandMember, [key]),
|
|
@@ -5309,17 +5804,19 @@ class CoreCommands(Protocol):
|
|
|
5309
5804
|
"""
|
|
5310
5805
|
Retrieves up to the absolute value of `count` random members from the sorted set stored at 'key'.
|
|
5311
5806
|
|
|
5312
|
-
See https://valkey.io/commands/zrandmember for more details.
|
|
5807
|
+
See [valkey.io](https://valkey.io/commands/zrandmember) for more details.
|
|
5313
5808
|
|
|
5314
5809
|
Args:
|
|
5315
5810
|
key (TEncodable): The key of the sorted set.
|
|
5316
5811
|
count (int): The number of members to return.
|
|
5317
|
-
|
|
5318
|
-
If `count` is
|
|
5812
|
+
|
|
5813
|
+
- If `count` is positive, returns unique members.
|
|
5814
|
+
- If `count` is negative, allows for duplicates members.
|
|
5319
5815
|
|
|
5320
5816
|
Returns:
|
|
5321
5817
|
List[bytes]: A list of members from the sorted set.
|
|
5322
|
-
|
|
5818
|
+
|
|
5819
|
+
If the sorted set does not exist or is empty, the response will be an empty list.
|
|
5323
5820
|
|
|
5324
5821
|
Examples:
|
|
5325
5822
|
>>> await client.zadd("my_sorted_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -5341,23 +5838,27 @@ class CoreCommands(Protocol):
|
|
|
5341
5838
|
Retrieves up to the absolute value of `count` random members along with their scores from the sorted set
|
|
5342
5839
|
stored at 'key'.
|
|
5343
5840
|
|
|
5344
|
-
See https://valkey.io/commands/zrandmember for more details.
|
|
5841
|
+
See [valkey.io](https://valkey.io/commands/zrandmember) for more details.
|
|
5345
5842
|
|
|
5346
5843
|
Args:
|
|
5347
5844
|
key (TEncodable): The key of the sorted set.
|
|
5348
5845
|
count (int): The number of members to return.
|
|
5349
|
-
|
|
5350
|
-
If `count` is
|
|
5846
|
+
|
|
5847
|
+
- If `count` is positive, returns unique members.
|
|
5848
|
+
- If `count` is negative, allows for duplicates members.
|
|
5351
5849
|
|
|
5352
5850
|
Returns:
|
|
5353
5851
|
List[List[Union[bytes, float]]]: A list of `[member, score]` lists, where `member` is a random member from
|
|
5354
|
-
|
|
5355
|
-
|
|
5852
|
+
the sorted set and `score` is the associated score.
|
|
5853
|
+
|
|
5854
|
+
If the sorted set does not exist or is empty, the response will be an empty list.
|
|
5356
5855
|
|
|
5357
5856
|
Examples:
|
|
5358
5857
|
>>> await client.zadd("my_sorted_set", {"member1": 1.0, "member2": 2.0})
|
|
5359
5858
|
>>> 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
|
|
5859
|
+
[[b"member1", 1.0], [b"member1", 1.0], [b"member2", 2.0]] # "member1" and "member2" are random members of
|
|
5860
|
+
# "my_sorted_set", and have scores of 1.0 and 2.0,
|
|
5861
|
+
# respectively.
|
|
5361
5862
|
>>> await client.zrandmember_withscores("non_existing_sorted_set", 3)
|
|
5362
5863
|
[] # "non_existing_sorted_set" is not an existing key, so an empty list was returned.
|
|
5363
5864
|
"""
|
|
@@ -5382,7 +5883,7 @@ class CoreCommands(Protocol):
|
|
|
5382
5883
|
|
|
5383
5884
|
The number of popped elements is the minimum from the sorted set's cardinality and `count`.
|
|
5384
5885
|
|
|
5385
|
-
See https://valkey.io/commands/zmpop for more details.
|
|
5886
|
+
See [valkey.io](https://valkey.io/commands/zmpop) for more details.
|
|
5386
5887
|
|
|
5387
5888
|
Note:
|
|
5388
5889
|
When in cluster mode, all `keys` must map to the same hash slot.
|
|
@@ -5395,14 +5896,16 @@ class CoreCommands(Protocol):
|
|
|
5395
5896
|
|
|
5396
5897
|
Returns:
|
|
5397
5898
|
Optional[List[Union[bytes, Mapping[bytes, float]]]]: A two-element list containing the key name of the set from
|
|
5398
|
-
|
|
5399
|
-
|
|
5899
|
+
which elements were popped, and a member-score mapping of the popped elements.
|
|
5900
|
+
|
|
5901
|
+
If no members could be popped, returns None.
|
|
5400
5902
|
|
|
5401
5903
|
Examples:
|
|
5402
5904
|
>>> await client.zadd("zSet1", {"one": 1.0, "two": 2.0, "three": 3.0})
|
|
5403
5905
|
>>> await client.zadd("zSet2", {"four": 4.0})
|
|
5404
5906
|
>>> 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
|
|
5907
|
+
[b'zSet1', {b'three': 3.0, b'two': 2.0}] # "three" with score 3.0 and "two" with score 2.0 were
|
|
5908
|
+
# popped from "zSet1".
|
|
5406
5909
|
|
|
5407
5910
|
Since: Valkey version 7.0.0.
|
|
5408
5911
|
"""
|
|
@@ -5432,11 +5935,13 @@ class CoreCommands(Protocol):
|
|
|
5432
5935
|
|
|
5433
5936
|
`BZMPOP` is the blocking variant of `ZMPOP`.
|
|
5434
5937
|
|
|
5435
|
-
See https://valkey.io/commands/bzmpop for more details.
|
|
5938
|
+
See [valkey.io](https://valkey.io/commands/bzmpop) for more details.
|
|
5436
5939
|
|
|
5437
5940
|
Notes:
|
|
5438
5941
|
1. When in cluster mode, all `keys` must map to the same hash slot.
|
|
5439
|
-
2. `BZMPOP` is a client blocking command, see
|
|
5942
|
+
2. `BZMPOP` is a client blocking command, see
|
|
5943
|
+
[blocking commands](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#blocking-commands)
|
|
5944
|
+
for more details and best practices.
|
|
5440
5945
|
|
|
5441
5946
|
Args:
|
|
5442
5947
|
keys (List[TEncodable]): The keys of the sorted sets.
|
|
@@ -5448,14 +5953,16 @@ class CoreCommands(Protocol):
|
|
|
5448
5953
|
|
|
5449
5954
|
Returns:
|
|
5450
5955
|
Optional[List[Union[bytes, Mapping[bytes, float]]]]: A two-element list containing the key name of the set from
|
|
5451
|
-
|
|
5452
|
-
|
|
5956
|
+
which elements were popped, and a member-score mapping of the popped elements.
|
|
5957
|
+
|
|
5958
|
+
If no members could be popped and the timeout expired, returns None.
|
|
5453
5959
|
|
|
5454
5960
|
Examples:
|
|
5455
5961
|
>>> await client.zadd("zSet1", {"one": 1.0, "two": 2.0, "three": 3.0})
|
|
5456
5962
|
>>> await client.zadd("zSet2", {"four": 4.0})
|
|
5457
5963
|
>>> 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
|
|
5964
|
+
[b'zSet1', {b'three': 3.0, b'two': 2.0}] # "three" with score 3.0 and "two" with score 2.0 were
|
|
5965
|
+
# popped from "zSet1".
|
|
5459
5966
|
|
|
5460
5967
|
Since: Valkey version 7.0.0.
|
|
5461
5968
|
"""
|
|
@@ -5476,16 +5983,16 @@ class CoreCommands(Protocol):
|
|
|
5476
5983
|
optional `limit` argument, if the intersection cardinality reaches `limit` partway through the computation, the
|
|
5477
5984
|
algorithm will exit early and yield `limit` as the cardinality.
|
|
5478
5985
|
|
|
5479
|
-
|
|
5986
|
+
Note:
|
|
5987
|
+
When in cluster mode, all `keys` must map to the same hash slot.
|
|
5988
|
+
|
|
5989
|
+
See [valkey.io](https://valkey.io/commands/zintercard) for more details.
|
|
5480
5990
|
|
|
5481
5991
|
Args:
|
|
5482
5992
|
keys (List[TEncodable]): The keys of the sorted sets to intersect.
|
|
5483
5993
|
limit (Optional[int]): An optional argument that can be used to specify a maximum number for the
|
|
5484
5994
|
intersection cardinality. If limit is not supplied, or if it is set to 0, there will be no limit.
|
|
5485
5995
|
|
|
5486
|
-
Note:
|
|
5487
|
-
When in cluster mode, all `keys` must map to the same hash slot.
|
|
5488
|
-
|
|
5489
5996
|
Returns:
|
|
5490
5997
|
int: The cardinality of the intersection of the given sorted sets, or the `limit` if reached.
|
|
5491
5998
|
|
|
@@ -5495,7 +6002,8 @@ class CoreCommands(Protocol):
|
|
|
5495
6002
|
>>> await client.zintercard(["key1", "key2"])
|
|
5496
6003
|
2 # Indicates that the intersection of the sorted sets at "key1" and "key2" has a cardinality of 2.
|
|
5497
6004
|
>>> 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
|
|
6005
|
+
1 # A `limit` of 1 was provided, so the intersection computation exits early and yields the `limit` value
|
|
6006
|
+
# of 1.
|
|
5499
6007
|
|
|
5500
6008
|
Since: Valkey version 7.0.0.
|
|
5501
6009
|
"""
|
|
@@ -5512,14 +6020,15 @@ class CoreCommands(Protocol):
|
|
|
5512
6020
|
"""
|
|
5513
6021
|
Returns the original source code of a script in the script cache.
|
|
5514
6022
|
|
|
5515
|
-
See https://valkey.io/commands/script-show for more details.
|
|
6023
|
+
See [valkey.io](https://valkey.io/commands/script-show) for more details.
|
|
5516
6024
|
|
|
5517
6025
|
Args:
|
|
5518
6026
|
sha1 (TEncodable): The SHA1 digest of the script.
|
|
5519
6027
|
|
|
5520
6028
|
Returns:
|
|
5521
6029
|
bytes: The original source code of the script, if present in the cache.
|
|
5522
|
-
|
|
6030
|
+
|
|
6031
|
+
If the script is not found in the cache, an error is thrown.
|
|
5523
6032
|
|
|
5524
6033
|
Example:
|
|
5525
6034
|
>>> await client.script_show(script.get_hash())
|
|
@@ -5535,24 +6044,26 @@ class CoreCommands(Protocol):
|
|
|
5535
6044
|
Creates a new structure if the `key` does not exist.
|
|
5536
6045
|
When no elements are provided, and `key` exists and is a HyperLogLog, then no operation is performed.
|
|
5537
6046
|
|
|
5538
|
-
See https://valkey.io/commands/pfadd/ for more details.
|
|
6047
|
+
See [valkey.io](https://valkey.io/commands/pfadd/) for more details.
|
|
5539
6048
|
|
|
5540
6049
|
Args:
|
|
5541
6050
|
key (TEncodable): The key of the HyperLogLog data structure to add elements into.
|
|
5542
6051
|
elements (List[TEncodable]): A list of members to add to the HyperLogLog stored at `key`.
|
|
5543
6052
|
|
|
5544
6053
|
Returns:
|
|
5545
|
-
|
|
5546
|
-
altered, then returns
|
|
6054
|
+
bool: If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
|
|
6055
|
+
altered, then returns `True`.
|
|
6056
|
+
|
|
6057
|
+
Otherwise, returns `False`.
|
|
5547
6058
|
|
|
5548
6059
|
Examples:
|
|
5549
6060
|
>>> await client.pfadd("hll_1", ["a", "b", "c" ])
|
|
5550
|
-
|
|
6061
|
+
True # A data structure was created or modified
|
|
5551
6062
|
>>> await client.pfadd("hll_2", [])
|
|
5552
|
-
|
|
6063
|
+
True # A new empty data structure was created
|
|
5553
6064
|
"""
|
|
5554
6065
|
return cast(
|
|
5555
|
-
|
|
6066
|
+
bool,
|
|
5556
6067
|
await self._execute_command(RequestType.PfAdd, [key] + elements),
|
|
5557
6068
|
)
|
|
5558
6069
|
|
|
@@ -5561,7 +6072,7 @@ class CoreCommands(Protocol):
|
|
|
5561
6072
|
Estimates the cardinality of the data stored in a HyperLogLog structure for a single key or
|
|
5562
6073
|
calculates the combined cardinality of multiple keys by merging their HyperLogLogs temporarily.
|
|
5563
6074
|
|
|
5564
|
-
See https://valkey.io/commands/pfcount for more details.
|
|
6075
|
+
See [valkey.io](https://valkey.io/commands/pfcount) for more details.
|
|
5565
6076
|
|
|
5566
6077
|
Note:
|
|
5567
6078
|
When in Cluster mode, all `keys` must map to the same hash slot.
|
|
@@ -5571,7 +6082,8 @@ class CoreCommands(Protocol):
|
|
|
5571
6082
|
|
|
5572
6083
|
Returns:
|
|
5573
6084
|
int: The approximated cardinality of given HyperLogLog data structures.
|
|
5574
|
-
|
|
6085
|
+
|
|
6086
|
+
The cardinality of a key that does not exist is 0.
|
|
5575
6087
|
|
|
5576
6088
|
Examples:
|
|
5577
6089
|
>>> await client.pfcount(["hll_1", "hll_2"])
|
|
@@ -5589,7 +6101,7 @@ class CoreCommands(Protocol):
|
|
|
5589
6101
|
Merges multiple HyperLogLog values into a unique value. If the destination variable exists, it is treated as one
|
|
5590
6102
|
of the source HyperLogLog data sets, otherwise a new HyperLogLog is created.
|
|
5591
6103
|
|
|
5592
|
-
See https://valkey.io/commands/pfmerge for more details.
|
|
6104
|
+
See [valkey.io](https://valkey.io/commands/pfmerge) for more details.
|
|
5593
6105
|
|
|
5594
6106
|
Note:
|
|
5595
6107
|
When in Cluster mode, all keys in `source_keys` and `destination` must map to the same hash slot.
|
|
@@ -5623,7 +6135,7 @@ class CoreCommands(Protocol):
|
|
|
5623
6135
|
Counts the number of set bits (population counting) in the string stored at `key`. The `options` argument can
|
|
5624
6136
|
optionally be provided to count the number of bits in a specific string interval.
|
|
5625
6137
|
|
|
5626
|
-
See https://valkey.io/commands/bitcount for more details.
|
|
6138
|
+
See [valkey.io](https://valkey.io/commands/bitcount) for more details.
|
|
5627
6139
|
|
|
5628
6140
|
Args:
|
|
5629
6141
|
key (TEncodable): The key for the string to count the set bits of.
|
|
@@ -5631,8 +6143,10 @@ class CoreCommands(Protocol):
|
|
|
5631
6143
|
|
|
5632
6144
|
Returns:
|
|
5633
6145
|
int: If `options` is provided, returns the number of set bits in the string interval specified by `options`.
|
|
5634
|
-
|
|
5635
|
-
|
|
6146
|
+
|
|
6147
|
+
If `options` is not provided, returns the number of set bits in the string stored at `key`.
|
|
6148
|
+
|
|
6149
|
+
Otherwise, if `key` is missing, returns `0` as it is treated as an empty string.
|
|
5636
6150
|
|
|
5637
6151
|
Examples:
|
|
5638
6152
|
>>> await client.bitcount("my_key1")
|
|
@@ -5662,7 +6176,7 @@ class CoreCommands(Protocol):
|
|
|
5662
6176
|
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
6177
|
`value` and the preceding bits are set to `0`.
|
|
5664
6178
|
|
|
5665
|
-
See https://valkey.io/commands/setbit for more details.
|
|
6179
|
+
See [valkey.io](https://valkey.io/commands/setbit) for more details.
|
|
5666
6180
|
|
|
5667
6181
|
Args:
|
|
5668
6182
|
key (TEncodable): The key of the string.
|
|
@@ -5688,15 +6202,16 @@ class CoreCommands(Protocol):
|
|
|
5688
6202
|
Returns the bit value at `offset` in the string value stored at `key`.
|
|
5689
6203
|
`offset` should be greater than or equal to zero.
|
|
5690
6204
|
|
|
5691
|
-
See https://valkey.io/commands/getbit for more details.
|
|
6205
|
+
See [valkey.io](https://valkey.io/commands/getbit) for more details.
|
|
5692
6206
|
|
|
5693
6207
|
Args:
|
|
5694
6208
|
key (TEncodable): The key of the string.
|
|
5695
6209
|
offset (int): The index of the bit to return.
|
|
5696
6210
|
|
|
5697
6211
|
Returns:
|
|
5698
|
-
int: The bit at the given `offset` of the string.
|
|
5699
|
-
|
|
6212
|
+
int: The bit at the given `offset` of the string.
|
|
6213
|
+
|
|
6214
|
+
Returns `0` if the key is empty or if the `offset` exceeds the length of the string.
|
|
5700
6215
|
|
|
5701
6216
|
Examples:
|
|
5702
6217
|
>>> await client.getbit("my_key", 1)
|
|
@@ -5721,7 +6236,7 @@ class CoreCommands(Protocol):
|
|
|
5721
6236
|
are assumed. If BIT is specified, `start=0` and `end=2` means to look at the first three bits. If BYTE is
|
|
5722
6237
|
specified, `start=0` and `end=2` means to look at the first three bytes.
|
|
5723
6238
|
|
|
5724
|
-
See https://valkey.io/commands/bitpos for more details.
|
|
6239
|
+
See [valkey.io](https://valkey.io/commands/bitpos) for more details.
|
|
5725
6240
|
|
|
5726
6241
|
Args:
|
|
5727
6242
|
key (TEncodable): The key of the string.
|
|
@@ -5730,20 +6245,24 @@ class CoreCommands(Protocol):
|
|
|
5730
6245
|
|
|
5731
6246
|
Returns:
|
|
5732
6247
|
int: The position of the first occurrence of `bit` in the binary value of the string held at `key`.
|
|
5733
|
-
|
|
6248
|
+
|
|
6249
|
+
If `start` was provided, the search begins at the offset indicated by `start`.
|
|
5734
6250
|
|
|
5735
6251
|
Examples:
|
|
5736
6252
|
>>> await client.set("key1", "A1") # "A1" has binary value 01000001 00110001
|
|
5737
6253
|
>>> await client.bitpos("key1", 1)
|
|
5738
6254
|
1 # The first occurrence of bit value 1 in the string stored at "key1" is at the second position.
|
|
5739
6255
|
>>> 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",
|
|
6256
|
+
10 # The first occurrence of bit value 1, starting at the last byte in the string stored at "key1",
|
|
6257
|
+
# is at the eleventh position.
|
|
5741
6258
|
|
|
5742
6259
|
>>> await client.set("key2", "A12") # "A12" has binary value 01000001 00110001 00110010
|
|
5743
6260
|
>>> 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"
|
|
6261
|
+
10 # The first occurrence of bit value 1 in the second byte to the last byte of the string stored at "key1"
|
|
6262
|
+
# is at the eleventh position.
|
|
5745
6263
|
>>> 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"
|
|
6264
|
+
7 # The first occurrence of bit value 1 in the third to tenth bits of the string stored at "key1"
|
|
6265
|
+
# is at the eighth position.
|
|
5747
6266
|
"""
|
|
5748
6267
|
args: List[TEncodable] = [key, str(bit)]
|
|
5749
6268
|
if options is not None:
|
|
@@ -5764,7 +6283,7 @@ class CoreCommands(Protocol):
|
|
|
5764
6283
|
Perform a bitwise operation between multiple keys (containing string values) and store the result in the
|
|
5765
6284
|
`destination`.
|
|
5766
6285
|
|
|
5767
|
-
See https://valkey.io/commands/bitop for more details.
|
|
6286
|
+
See [valkey.io](https://valkey.io/commands/bitop) for more details.
|
|
5768
6287
|
|
|
5769
6288
|
Note:
|
|
5770
6289
|
When in cluster mode, `destination` and all `keys` must map to the same hash slot.
|
|
@@ -5799,12 +6318,13 @@ class CoreCommands(Protocol):
|
|
|
5799
6318
|
Reads or modifies the array of bits representing the string that is held at `key` based on the specified
|
|
5800
6319
|
`subcommands`.
|
|
5801
6320
|
|
|
5802
|
-
See https://valkey.io/commands/bitfield for more details.
|
|
6321
|
+
See [valkey.io](https://valkey.io/commands/bitfield) for more details.
|
|
5803
6322
|
|
|
5804
6323
|
Args:
|
|
5805
6324
|
key (TEncodable): The key of the string.
|
|
5806
6325
|
subcommands (List[BitFieldSubCommands]): The subcommands to be performed on the binary value of the string
|
|
5807
6326
|
at `key`, which could be any of the following:
|
|
6327
|
+
|
|
5808
6328
|
- `BitFieldGet`
|
|
5809
6329
|
- `BitFieldSet`
|
|
5810
6330
|
- `BitFieldIncrBy`
|
|
@@ -5812,6 +6332,7 @@ class CoreCommands(Protocol):
|
|
|
5812
6332
|
|
|
5813
6333
|
Returns:
|
|
5814
6334
|
List[Optional[int]]: An array of results from the executed subcommands:
|
|
6335
|
+
|
|
5815
6336
|
- `BitFieldGet` returns the value in `BitOffset` or `BitOffsetMultiplier`.
|
|
5816
6337
|
- `BitFieldSet` returns the old value in `BitOffset` or `BitOffsetMultiplier`.
|
|
5817
6338
|
- `BitFieldIncrBy` returns the new value in `BitOffset` or `BitOffsetMultiplier`.
|
|
@@ -5821,8 +6342,12 @@ class CoreCommands(Protocol):
|
|
|
5821
6342
|
|
|
5822
6343
|
Examples:
|
|
5823
6344
|
>>> await client.set("my_key", "A") # "A" has binary value 01000001
|
|
5824
|
-
>>> await client.bitfield(
|
|
5825
|
-
|
|
6345
|
+
>>> await client.bitfield(
|
|
6346
|
+
... "my_key",
|
|
6347
|
+
... [BitFieldSet(UnsignedEncoding(2), BitOffset(1), 3), BitFieldGet(UnsignedEncoding(2), BitOffset(1))]
|
|
6348
|
+
... )
|
|
6349
|
+
[2, 3] # The old value at offset 1 with an unsigned encoding of 2 was 2. The new value at offset 1 with an
|
|
6350
|
+
# unsigned encoding of 2 is 3.
|
|
5826
6351
|
"""
|
|
5827
6352
|
args = [key] + _create_bitfield_args(subcommands)
|
|
5828
6353
|
return cast(
|
|
@@ -5836,7 +6361,7 @@ class CoreCommands(Protocol):
|
|
|
5836
6361
|
"""
|
|
5837
6362
|
Reads the array of bits representing the string that is held at `key` based on the specified `subcommands`.
|
|
5838
6363
|
|
|
5839
|
-
See https://valkey.io/commands/bitfield_ro for more details.
|
|
6364
|
+
See [valkey.io](https://valkey.io/commands/bitfield_ro) for more details.
|
|
5840
6365
|
|
|
5841
6366
|
Args:
|
|
5842
6367
|
key (TEncodable): The key of the string.
|
|
@@ -5862,14 +6387,16 @@ class CoreCommands(Protocol):
|
|
|
5862
6387
|
"""
|
|
5863
6388
|
Returns the internal encoding for the Valkey object stored at `key`.
|
|
5864
6389
|
|
|
5865
|
-
See https://valkey.io/commands/object-encoding for more details.
|
|
6390
|
+
See [valkey.io](https://valkey.io/commands/object-encoding) for more details.
|
|
5866
6391
|
|
|
5867
6392
|
Args:
|
|
5868
6393
|
key (TEncodable): The `key` of the object to get the internal encoding of.
|
|
5869
6394
|
|
|
5870
6395
|
Returns:
|
|
5871
6396
|
Optional[bytes]: If `key` exists, returns the internal encoding of the object stored at
|
|
5872
|
-
|
|
6397
|
+
`key` as a bytes string.
|
|
6398
|
+
|
|
6399
|
+
Otherwise, returns None.
|
|
5873
6400
|
|
|
5874
6401
|
Examples:
|
|
5875
6402
|
>>> await client.object_encoding("my_hash")
|
|
@@ -5884,14 +6411,16 @@ class CoreCommands(Protocol):
|
|
|
5884
6411
|
"""
|
|
5885
6412
|
Returns the logarithmic access frequency counter of a Valkey object stored at `key`.
|
|
5886
6413
|
|
|
5887
|
-
See https://valkey.io/commands/object-freq for more details.
|
|
6414
|
+
See [valkey.io](https://valkey.io/commands/object-freq) for more details.
|
|
5888
6415
|
|
|
5889
6416
|
Args:
|
|
5890
6417
|
key (TEncodable): The key of the object to get the logarithmic access frequency counter of.
|
|
5891
6418
|
|
|
5892
6419
|
Returns:
|
|
5893
|
-
Optional[int]: If `key` exists, returns the logarithmic access frequency counter of the object stored at `key` as
|
|
5894
|
-
|
|
6420
|
+
Optional[int]: If `key` exists, returns the logarithmic access frequency counter of the object stored at `key` as
|
|
6421
|
+
an integer.
|
|
6422
|
+
|
|
6423
|
+
Otherwise, returns None.
|
|
5895
6424
|
|
|
5896
6425
|
Examples:
|
|
5897
6426
|
>>> await client.object_freq("my_hash")
|
|
@@ -5906,13 +6435,15 @@ class CoreCommands(Protocol):
|
|
|
5906
6435
|
"""
|
|
5907
6436
|
Returns the time in seconds since the last access to the value stored at `key`.
|
|
5908
6437
|
|
|
5909
|
-
See https://valkey.io/commands/object-idletime for more details.
|
|
6438
|
+
See [valkey.io](https://valkey.io/commands/object-idletime) for more details.
|
|
5910
6439
|
|
|
5911
6440
|
Args:
|
|
5912
6441
|
key (TEncodable): The key of the object to get the idle time of.
|
|
5913
6442
|
|
|
5914
6443
|
Returns:
|
|
5915
|
-
Optional[int]: If `key` exists, returns the idle time in seconds.
|
|
6444
|
+
Optional[int]: If `key` exists, returns the idle time in seconds.
|
|
6445
|
+
|
|
6446
|
+
Otherwise, returns None.
|
|
5916
6447
|
|
|
5917
6448
|
Examples:
|
|
5918
6449
|
>>> await client.object_idletime("my_hash")
|
|
@@ -5927,14 +6458,15 @@ class CoreCommands(Protocol):
|
|
|
5927
6458
|
"""
|
|
5928
6459
|
Returns the reference count of the object stored at `key`.
|
|
5929
6460
|
|
|
5930
|
-
See https://valkey.io/commands/object-refcount for more details.
|
|
6461
|
+
See [valkey.io](https://valkey.io/commands/object-refcount) for more details.
|
|
5931
6462
|
|
|
5932
6463
|
Args:
|
|
5933
6464
|
key (TEncodable): The key of the object to get the reference count of.
|
|
5934
6465
|
|
|
5935
6466
|
Returns:
|
|
5936
6467
|
Optional[int]: If `key` exists, returns the reference count of the object stored at `key` as an integer.
|
|
5937
|
-
|
|
6468
|
+
|
|
6469
|
+
Otherwise, returns None.
|
|
5938
6470
|
|
|
5939
6471
|
Examples:
|
|
5940
6472
|
>>> await client.object_refcount("my_hash")
|
|
@@ -5949,13 +6481,15 @@ class CoreCommands(Protocol):
|
|
|
5949
6481
|
"""
|
|
5950
6482
|
Returns a random element from the set value stored at 'key'.
|
|
5951
6483
|
|
|
5952
|
-
See https://valkey.io/commands/srandmember for more details.
|
|
6484
|
+
See [valkey.io](https://valkey.io/commands/srandmember) for more details.
|
|
5953
6485
|
|
|
5954
6486
|
Args:
|
|
5955
6487
|
key (TEncodable): The key from which to retrieve the set member.
|
|
5956
6488
|
|
|
5957
6489
|
Returns:
|
|
5958
|
-
Optional[bytes]: A random element from the set
|
|
6490
|
+
Optional[bytes]: A random element from the set.
|
|
6491
|
+
|
|
6492
|
+
`None` if 'key' does not exist.
|
|
5959
6493
|
|
|
5960
6494
|
Examples:
|
|
5961
6495
|
>>> await client.sadd("my_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -5974,17 +6508,19 @@ class CoreCommands(Protocol):
|
|
|
5974
6508
|
"""
|
|
5975
6509
|
Returns one or more random elements from the set value stored at 'key'.
|
|
5976
6510
|
|
|
5977
|
-
See https://valkey.io/commands/srandmember for more details.
|
|
6511
|
+
See [valkey.io](https://valkey.io/commands/srandmember) for more details.
|
|
5978
6512
|
|
|
5979
6513
|
Args:
|
|
5980
6514
|
key (TEncodable): The key of the sorted set.
|
|
5981
6515
|
count (int): The number of members to return.
|
|
5982
|
-
|
|
5983
|
-
If `count` is
|
|
6516
|
+
|
|
6517
|
+
- If `count` is positive, returns unique members.
|
|
6518
|
+
- If `count` is negative, allows for duplicates members.
|
|
5984
6519
|
|
|
5985
6520
|
Returns:
|
|
5986
6521
|
List[bytes]: A list of members from the set.
|
|
5987
|
-
|
|
6522
|
+
|
|
6523
|
+
If the set does not exist or is empty, the response will be an empty list.
|
|
5988
6524
|
|
|
5989
6525
|
Examples:
|
|
5990
6526
|
>>> await client.sadd("my_set", {"member1": 1.0, "member2": 2.0})
|
|
@@ -6005,7 +6541,8 @@ class CoreCommands(Protocol):
|
|
|
6005
6541
|
) -> Optional[bytes]:
|
|
6006
6542
|
"""
|
|
6007
6543
|
Get the value of `key` and optionally set its expiration. `GETEX` is similar to `GET`.
|
|
6008
|
-
|
|
6544
|
+
|
|
6545
|
+
See [valkey.io](https://valkey.io/commands/getex) for more details.
|
|
6009
6546
|
|
|
6010
6547
|
Args:
|
|
6011
6548
|
key (TEncodable): The key to get.
|
|
@@ -6013,9 +6550,9 @@ class CoreCommands(Protocol):
|
|
|
6013
6550
|
Equivalent to [`EX` | `PX` | `EXAT` | `PXAT` | `PERSIST`] in the Valkey API.
|
|
6014
6551
|
|
|
6015
6552
|
Returns:
|
|
6016
|
-
Optional[bytes]:
|
|
6017
|
-
|
|
6018
|
-
|
|
6553
|
+
Optional[bytes]: If `key` exists, return the value stored at `key`
|
|
6554
|
+
|
|
6555
|
+
If `key` does not exist, return `None`
|
|
6019
6556
|
|
|
6020
6557
|
Examples:
|
|
6021
6558
|
>>> await client.set("key", "value")
|
|
@@ -6045,14 +6582,15 @@ class CoreCommands(Protocol):
|
|
|
6045
6582
|
"""
|
|
6046
6583
|
Serialize the value stored at `key` in a Valkey-specific format and return it to the user.
|
|
6047
6584
|
|
|
6048
|
-
See https://valkey.io/commands/dump for more details.
|
|
6585
|
+
See [valkey.io](https://valkey.io/commands/dump) for more details.
|
|
6049
6586
|
|
|
6050
6587
|
Args:
|
|
6051
6588
|
key (TEncodable): The `key` to serialize.
|
|
6052
6589
|
|
|
6053
6590
|
Returns:
|
|
6054
6591
|
Optional[bytes]: The serialized value of the data stored at `key`.
|
|
6055
|
-
|
|
6592
|
+
|
|
6593
|
+
If `key` does not exist, `None` will be returned.
|
|
6056
6594
|
|
|
6057
6595
|
Examples:
|
|
6058
6596
|
>>> await client.dump("key")
|
|
@@ -6079,14 +6617,15 @@ class CoreCommands(Protocol):
|
|
|
6079
6617
|
Create a `key` associated with a `value` that is obtained by deserializing the provided
|
|
6080
6618
|
serialized `value` obtained via `dump`.
|
|
6081
6619
|
|
|
6082
|
-
See https://valkey.io/commands/restore for more details.
|
|
6620
|
+
See [valkey.io](https://valkey.io/commands/restore) for more details.
|
|
6083
6621
|
|
|
6084
|
-
Note:
|
|
6622
|
+
Note:
|
|
6623
|
+
`IDLETIME` and `FREQ` modifiers cannot be set at the same time.
|
|
6085
6624
|
|
|
6086
6625
|
Args:
|
|
6087
6626
|
key (TEncodable): The `key` to create.
|
|
6088
6627
|
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`.
|
|
6628
|
+
value (TEncodable): The serialized value to deserialize and assign to `key`.
|
|
6090
6629
|
replace (bool): Set to `True` to replace the key if it exists.
|
|
6091
6630
|
absttl (bool): Set to `True` to specify that `ttl` represents an absolute Unix
|
|
6092
6631
|
timestamp (in milliseconds).
|
|
@@ -6113,6 +6652,10 @@ class CoreCommands(Protocol):
|
|
|
6113
6652
|
args.append("REPLACE")
|
|
6114
6653
|
if absttl is True:
|
|
6115
6654
|
args.append("ABSTTL")
|
|
6655
|
+
if idletime is not None and frequency is not None:
|
|
6656
|
+
raise RequestError(
|
|
6657
|
+
"syntax error: IDLETIME and FREQ cannot be set at the same time."
|
|
6658
|
+
)
|
|
6116
6659
|
if idletime is not None:
|
|
6117
6660
|
args.extend(["IDLETIME", str(idletime)])
|
|
6118
6661
|
if frequency is not None:
|
|
@@ -6132,29 +6675,30 @@ class CoreCommands(Protocol):
|
|
|
6132
6675
|
"""
|
|
6133
6676
|
Iterates incrementally over a set.
|
|
6134
6677
|
|
|
6135
|
-
See https://valkey.io/commands/sscan for more details.
|
|
6678
|
+
See [valkey.io](https://valkey.io/commands/sscan) for more details.
|
|
6136
6679
|
|
|
6137
6680
|
Args:
|
|
6138
6681
|
key (TEncodable): The key of the set.
|
|
6139
6682
|
cursor (TEncodable): The cursor that points to the next iteration of results. A value of "0" indicates the start of
|
|
6140
6683
|
the search.
|
|
6141
6684
|
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.
|
|
6685
|
+
strings or byte strings that match the pattern specified. If the set is large enough for scan commands to
|
|
6686
|
+
return only a subset of the set then there could be a case where the result is empty although there are
|
|
6687
|
+
items that match the pattern specified. This is due to the default `COUNT` being `10` which indicates
|
|
6688
|
+
that it will only fetch and match `10` items from the list.
|
|
6146
6689
|
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the set.
|
|
6147
6690
|
`COUNT` could be ignored until the set is large enough for the `SCAN` commands to represent the results
|
|
6148
6691
|
as compact single-allocation packed encoding.
|
|
6149
6692
|
|
|
6150
6693
|
Returns:
|
|
6151
6694
|
List[Union[bytes, List[bytes]]]: An `Array` of the `cursor` and the subset of the set held by `key`.
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6695
|
+
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
|
|
6696
|
+
returned on the last iteration of the set. The second element is always an `Array` of the subset of the
|
|
6697
|
+
set held in `key`.
|
|
6155
6698
|
|
|
6156
6699
|
Examples:
|
|
6157
|
-
|
|
6700
|
+
Assume "key" contains a set with 130 members:
|
|
6701
|
+
|
|
6158
6702
|
>>> result_cursor = "0"
|
|
6159
6703
|
>>> while True:
|
|
6160
6704
|
... result = await client.sscan("key", "0", match="*")
|
|
@@ -6193,16 +6737,16 @@ class CoreCommands(Protocol):
|
|
|
6193
6737
|
"""
|
|
6194
6738
|
Iterates incrementally over a sorted set.
|
|
6195
6739
|
|
|
6196
|
-
See https://valkey.io/commands/zscan for more details.
|
|
6740
|
+
See [valkey.io](https://valkey.io/commands/zscan) for more details.
|
|
6197
6741
|
|
|
6198
6742
|
Args:
|
|
6199
6743
|
key (TEncodable): The key of the sorted set.
|
|
6200
6744
|
cursor (TEncodable): The cursor that points to the next iteration of results. A value of "0" indicates the start of
|
|
6201
6745
|
the search.
|
|
6202
6746
|
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
|
|
6747
|
+
strings or byte strings that match the pattern specified. If the sorted set is large enough for scan commands
|
|
6748
|
+
to return only a subset of the sorted set then there could be a case where the result is empty although there
|
|
6749
|
+
are items that match the pattern specified. This is due to the default `COUNT` being `10` which indicates
|
|
6206
6750
|
that it will only fetch and match `10` items from the list.
|
|
6207
6751
|
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the
|
|
6208
6752
|
sorted set. `COUNT` could be ignored until the sorted set is large enough for the `SCAN` commands to
|
|
@@ -6215,10 +6759,12 @@ class CoreCommands(Protocol):
|
|
|
6215
6759
|
returned on the last iteration of the sorted set. The second element is always an `Array` of the subset
|
|
6216
6760
|
of the sorted set held in `key`. The `Array` in the second element is a flattened series of
|
|
6217
6761
|
`String` pairs, where the value is at even indices and the score is at odd indices.
|
|
6218
|
-
|
|
6762
|
+
|
|
6763
|
+
If `no_scores` is set to `True`, the second element will only contain the members without scores.
|
|
6219
6764
|
|
|
6220
6765
|
Examples:
|
|
6221
|
-
|
|
6766
|
+
Assume "key" contains a sorted set with multiple members:
|
|
6767
|
+
|
|
6222
6768
|
>>> result_cursor = "0"
|
|
6223
6769
|
>>> while True:
|
|
6224
6770
|
... result = await client.zscan("key", "0", match="*", count=5)
|
|
@@ -6235,7 +6781,8 @@ class CoreCommands(Protocol):
|
|
|
6235
6781
|
Cursor: 0
|
|
6236
6782
|
Members: [b'value 55', b'55', b'value 24', b'24', b'value 90', b'90', b'value 113', b'113']
|
|
6237
6783
|
|
|
6238
|
-
|
|
6784
|
+
Using no-score:
|
|
6785
|
+
|
|
6239
6786
|
>>> result_cursor = "0"
|
|
6240
6787
|
>>> while True:
|
|
6241
6788
|
... result = await client.zscan("key", "0", match="*", count=5, no_scores=True)
|
|
@@ -6276,17 +6823,17 @@ class CoreCommands(Protocol):
|
|
|
6276
6823
|
"""
|
|
6277
6824
|
Iterates incrementally over a hash.
|
|
6278
6825
|
|
|
6279
|
-
See https://valkey.io/commands/hscan for more details.
|
|
6826
|
+
See [valkey.io](https://valkey.io/commands/hscan) for more details.
|
|
6280
6827
|
|
|
6281
6828
|
Args:
|
|
6282
6829
|
key (TEncodable): The key of the set.
|
|
6283
6830
|
cursor (TEncodable): The cursor that points to the next iteration of results. A value of "0" indicates the start of
|
|
6284
6831
|
the search.
|
|
6285
6832
|
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.
|
|
6833
|
+
strings or byte strings that match the pattern specified. If the hash is large enough for scan commands to
|
|
6834
|
+
return only a subset of the hash then there could be a case where the result is empty although there are
|
|
6835
|
+
items that match the pattern specified. This is due to the default `COUNT` being `10` which indicates that it
|
|
6836
|
+
will only fetch and match `10` items from the list.
|
|
6290
6837
|
count (Optional[int]): `COUNT` is a just a hint for the command for how many elements to fetch from the hash.
|
|
6291
6838
|
`COUNT` could be ignored until the hash is large enough for the `SCAN` commands to represent the results
|
|
6292
6839
|
as compact single-allocation packed encoding.
|
|
@@ -6294,14 +6841,16 @@ class CoreCommands(Protocol):
|
|
|
6294
6841
|
|
|
6295
6842
|
Returns:
|
|
6296
6843
|
List[Union[bytes, List[bytes]]]: An `Array` of the `cursor` and the subset of the hash held by `key`.
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6844
|
+
The first element is always the `cursor` for the next iteration of results. `0` will be the `cursor`
|
|
6845
|
+
returned on the last iteration of the hash. The second element is always an `Array` of the subset of the
|
|
6846
|
+
hash held in `key`. The `Array` in the second element is a flattened series of `String` pairs,
|
|
6847
|
+
where the value is at even indices and the score is at odd indices.
|
|
6848
|
+
|
|
6849
|
+
If `no_values` is set to `True`, the second element will only contain the fields without the values.
|
|
6302
6850
|
|
|
6303
6851
|
Examples:
|
|
6304
|
-
|
|
6852
|
+
Assume "key" contains a hash with multiple members:
|
|
6853
|
+
|
|
6305
6854
|
>>> result_cursor = "0"
|
|
6306
6855
|
>>> while True:
|
|
6307
6856
|
... result = await client.hscan("key", "0", match="*", count=3)
|
|
@@ -6318,7 +6867,8 @@ class CoreCommands(Protocol):
|
|
|
6318
6867
|
Cursor: 0
|
|
6319
6868
|
Members: [b'field 420', b'value 420', b'field 221', b'value 221']
|
|
6320
6869
|
|
|
6321
|
-
|
|
6870
|
+
Use no-values:
|
|
6871
|
+
|
|
6322
6872
|
>>> result_cursor = "0"
|
|
6323
6873
|
>>> while True:
|
|
6324
6874
|
... result = await client.hscan("key", "0", match="*", count=3, no_values=True)
|
|
@@ -6356,8 +6906,12 @@ class CoreCommands(Protocol):
|
|
|
6356
6906
|
) -> TResult:
|
|
6357
6907
|
"""
|
|
6358
6908
|
Invokes a previously loaded function.
|
|
6359
|
-
|
|
6360
|
-
|
|
6909
|
+
|
|
6910
|
+
See [valkey.io](https://valkey.io/commands/fcall/) for more details.
|
|
6911
|
+
|
|
6912
|
+
Note:
|
|
6913
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
6914
|
+
|
|
6361
6915
|
Args:
|
|
6362
6916
|
function (TEncodable): The function name.
|
|
6363
6917
|
keys (Optional[List[TEncodable]]): A list of keys accessed by the function. To ensure the correct
|
|
@@ -6365,9 +6919,10 @@ class CoreCommands(Protocol):
|
|
|
6365
6919
|
that a function accesses must be explicitly provided as `keys`.
|
|
6366
6920
|
arguments (Optional[List[TEncodable]]): A list of `function` arguments. `Arguments`
|
|
6367
6921
|
should not represent names of keys.
|
|
6922
|
+
|
|
6368
6923
|
Returns:
|
|
6369
|
-
TResult:
|
|
6370
|
-
|
|
6924
|
+
TResult: The invoked function's return value.
|
|
6925
|
+
|
|
6371
6926
|
Example:
|
|
6372
6927
|
>>> await client.fcall("Deep_Thought")
|
|
6373
6928
|
b'new_value' # Returns the function's return value.
|
|
@@ -6395,9 +6950,10 @@ class CoreCommands(Protocol):
|
|
|
6395
6950
|
"""
|
|
6396
6951
|
Invokes a previously loaded read-only function.
|
|
6397
6952
|
|
|
6398
|
-
See https://valkey.io/commands/fcall_ro for more details.
|
|
6953
|
+
See [valkey.io](https://valkey.io/commands/fcall_ro) for more details.
|
|
6399
6954
|
|
|
6400
|
-
|
|
6955
|
+
Note:
|
|
6956
|
+
When in cluster mode, all keys in `keys` must map to the same hash slot.
|
|
6401
6957
|
|
|
6402
6958
|
Args:
|
|
6403
6959
|
function (TEncodable): The function name.
|
|
@@ -6431,11 +6987,11 @@ class CoreCommands(Protocol):
|
|
|
6431
6987
|
|
|
6432
6988
|
async def watch(self, keys: List[TEncodable]) -> TOK:
|
|
6433
6989
|
"""
|
|
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
|
|
6990
|
+
Marks the given keys to be watched for conditional execution of an atomic batch (Transaction).
|
|
6991
|
+
Transactions will only execute commands if the watched keys are not modified before execution of the
|
|
6436
6992
|
transaction.
|
|
6437
6993
|
|
|
6438
|
-
See https://valkey.io/commands/watch for more details.
|
|
6994
|
+
See [valkey.io](https://valkey.io/commands/watch) for more details.
|
|
6439
6995
|
|
|
6440
6996
|
Note:
|
|
6441
6997
|
In cluster mode, if keys in `key_value_map` map to different hash slots,
|
|
@@ -6492,10 +7048,11 @@ class CoreCommands(Protocol):
|
|
|
6492
7048
|
"""
|
|
6493
7049
|
Returns the next pubsub message.
|
|
6494
7050
|
Throws WrongConfiguration in cases:
|
|
6495
|
-
1. No pubsub subscriptions are configured for the client
|
|
6496
|
-
2. Callback is configured with the pubsub subsciptions
|
|
6497
7051
|
|
|
6498
|
-
|
|
7052
|
+
1. No pubsub subscriptions are configured for the client
|
|
7053
|
+
2. Callback is configured with the pubsub subsciptions
|
|
7054
|
+
|
|
7055
|
+
See [valkey.io](https://valkey.io/docs/topics/pubsub/) for more details.
|
|
6499
7056
|
|
|
6500
7057
|
Returns:
|
|
6501
7058
|
PubSubMsg: The next pubsub message
|
|
@@ -6509,10 +7066,11 @@ class CoreCommands(Protocol):
|
|
|
6509
7066
|
"""
|
|
6510
7067
|
Tries to return the next pubsub message.
|
|
6511
7068
|
Throws WrongConfiguration in cases:
|
|
6512
|
-
1. No pubsub subscriptions are configured for the client
|
|
6513
|
-
2. Callback is configured with the pubsub subsciptions
|
|
6514
7069
|
|
|
6515
|
-
|
|
7070
|
+
1. No pubsub subscriptions are configured for the client
|
|
7071
|
+
2. Callback is configured with the pubsub subsciptions
|
|
7072
|
+
|
|
7073
|
+
See [valkey.io](https://valkey.io/docs/topics/pubsub/) for more details.
|
|
6516
7074
|
|
|
6517
7075
|
Returns:
|
|
6518
7076
|
Optional[PubSubMsg]: The next pubsub message or None
|
|
@@ -6530,20 +7088,22 @@ class CoreCommands(Protocol):
|
|
|
6530
7088
|
"""
|
|
6531
7089
|
Returns the longest common subsequence between strings stored at key1 and key2.
|
|
6532
7090
|
|
|
6533
|
-
Note
|
|
6534
|
-
|
|
7091
|
+
Note:
|
|
7092
|
+
This is different than the longest common string algorithm, since
|
|
7093
|
+
matching characters in the two strings do not need to be contiguous.
|
|
6535
7094
|
|
|
6536
|
-
|
|
6537
|
-
|
|
7095
|
+
For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings
|
|
7096
|
+
from left to right, the longest common set of characters is composed of the first "f" and then the "o".
|
|
6538
7097
|
|
|
6539
|
-
See https://valkey.io/commands/lcs for more details.
|
|
7098
|
+
See [valkey.io](https://valkey.io/commands/lcs) for more details.
|
|
6540
7099
|
|
|
6541
7100
|
Args:
|
|
6542
7101
|
key1 (TEncodable): The key that stores the first string.
|
|
6543
7102
|
key2 (TEncodable): The key that stores the second string.
|
|
6544
7103
|
|
|
6545
7104
|
Returns:
|
|
6546
|
-
A Bytes String containing the longest common subsequence between the 2 strings.
|
|
7105
|
+
bytes: A Bytes String containing the longest common subsequence between the 2 strings.
|
|
7106
|
+
|
|
6547
7107
|
An empty String is returned if the keys do not exist or have no common subsequences.
|
|
6548
7108
|
|
|
6549
7109
|
Examples:
|
|
@@ -6569,13 +7129,14 @@ class CoreCommands(Protocol):
|
|
|
6569
7129
|
"""
|
|
6570
7130
|
Returns the length of the longest common subsequence between strings stored at key1 and key2.
|
|
6571
7131
|
|
|
6572
|
-
Note
|
|
6573
|
-
|
|
7132
|
+
Note:
|
|
7133
|
+
This is different than the longest common string algorithm, since
|
|
7134
|
+
matching characters in the two strings do not need to be contiguous.
|
|
6574
7135
|
|
|
6575
|
-
|
|
6576
|
-
|
|
7136
|
+
For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings
|
|
7137
|
+
from left to right, the longest common set of characters is composed of the first "f" and then the "o".
|
|
6577
7138
|
|
|
6578
|
-
See https://valkey.io/commands/lcs for more details.
|
|
7139
|
+
See [valkey.io](https://valkey.io/commands/lcs) for more details.
|
|
6579
7140
|
|
|
6580
7141
|
Args:
|
|
6581
7142
|
key1 (TEncodable): The key that stores the first string value.
|
|
@@ -6609,13 +7170,14 @@ class CoreCommands(Protocol):
|
|
|
6609
7170
|
"""
|
|
6610
7171
|
Returns the indices and length of the longest common subsequence between strings stored at key1 and key2.
|
|
6611
7172
|
|
|
6612
|
-
Note
|
|
6613
|
-
|
|
7173
|
+
Note:
|
|
7174
|
+
This is different than the longest common string algorithm, since
|
|
7175
|
+
matching characters in the two strings do not need to be contiguous.
|
|
6614
7176
|
|
|
6615
|
-
|
|
6616
|
-
|
|
7177
|
+
For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings
|
|
7178
|
+
from left to right, the longest common set of characters is composed of the first "f" and then the "o".
|
|
6617
7179
|
|
|
6618
|
-
See https://valkey.io/commands/lcs for more details.
|
|
7180
|
+
See [valkey.io](https://valkey.io/commands/lcs) for more details.
|
|
6619
7181
|
|
|
6620
7182
|
Args:
|
|
6621
7183
|
key1 (TEncodable): The key that stores the first string value.
|
|
@@ -6627,6 +7189,7 @@ class CoreCommands(Protocol):
|
|
|
6627
7189
|
A Mapping containing the indices of the longest common subsequence between the
|
|
6628
7190
|
2 strings and the length of the longest common subsequence. The resulting map contains two
|
|
6629
7191
|
keys, "matches" and "len":
|
|
7192
|
+
|
|
6630
7193
|
- "len" is mapped to the length of the longest common subsequence between the 2 strings.
|
|
6631
7194
|
- "matches" is mapped to a three dimensional int array that stores pairs of indices that
|
|
6632
7195
|
represent the location of the common subsequences in the strings held by key1 and key2,
|
|
@@ -6704,7 +7267,7 @@ class CoreCommands(Protocol):
|
|
|
6704
7267
|
Returns the index or indexes of element(s) matching `element` in the `key` list. If no match is found,
|
|
6705
7268
|
None is returned.
|
|
6706
7269
|
|
|
6707
|
-
See https://valkey.io/commands/lpos for more details.
|
|
7270
|
+
See [valkey.io](https://valkey.io/commands/lpos) for more details.
|
|
6708
7271
|
|
|
6709
7272
|
Args:
|
|
6710
7273
|
key (TEncodable): The name of the list.
|
|
@@ -6712,11 +7275,13 @@ class CoreCommands(Protocol):
|
|
|
6712
7275
|
rank (Optional[int]): The rank of the match to return.
|
|
6713
7276
|
count (Optional[int]): The number of matches wanted. A `count` of 0 returns all the matches.
|
|
6714
7277
|
max_len (Optional[int]): The maximum number of comparisons to make between the element and the items
|
|
6715
|
-
|
|
7278
|
+
in the list. A `max_len` of 0 means unlimited amount of comparisons.
|
|
6716
7279
|
|
|
6717
7280
|
Returns:
|
|
6718
|
-
Union[int, List[int], None]: The index of the first occurrence of `element
|
|
6719
|
-
|
|
7281
|
+
Union[int, List[int], None]: The index of the first occurrence of `element`.
|
|
7282
|
+
|
|
7283
|
+
`None` if `element` is not in the list.
|
|
7284
|
+
|
|
6720
7285
|
With the `count` option, a list of indices of matching elements will be returned.
|
|
6721
7286
|
|
|
6722
7287
|
Examples:
|
|
@@ -6757,15 +7322,16 @@ class CoreCommands(Protocol):
|
|
|
6757
7322
|
Lists the currently active channels.
|
|
6758
7323
|
The command is routed to all nodes, and aggregates the response to a single array.
|
|
6759
7324
|
|
|
6760
|
-
See https://valkey.io/commands/pubsub-channels for more details.
|
|
7325
|
+
See [valkey.io](https://valkey.io/commands/pubsub-channels) for more details.
|
|
6761
7326
|
|
|
6762
7327
|
Args:
|
|
6763
7328
|
pattern (Optional[TEncodable]): A glob-style pattern to match active channels.
|
|
6764
|
-
|
|
7329
|
+
If not provided, all active channels are returned.
|
|
6765
7330
|
|
|
6766
7331
|
Returns:
|
|
6767
7332
|
List[bytes]: A list of currently active channels matching the given pattern.
|
|
6768
|
-
|
|
7333
|
+
|
|
7334
|
+
If no pattern is specified, all active channels are returned.
|
|
6769
7335
|
|
|
6770
7336
|
Examples:
|
|
6771
7337
|
>>> await client.pubsub_channels()
|
|
@@ -6786,11 +7352,13 @@ class CoreCommands(Protocol):
|
|
|
6786
7352
|
"""
|
|
6787
7353
|
Returns the number of unique patterns that are subscribed to by clients.
|
|
6788
7354
|
|
|
6789
|
-
Note:
|
|
6790
|
-
|
|
6791
|
-
|
|
7355
|
+
Note:
|
|
7356
|
+
This is the total number of unique patterns all the clients are subscribed to,
|
|
7357
|
+
not the count of clients subscribed to patterns.
|
|
6792
7358
|
|
|
6793
|
-
|
|
7359
|
+
The command is routed to all nodes, and aggregates the response the sum of all pattern subscriptions.
|
|
7360
|
+
|
|
7361
|
+
See [valkey.io](https://valkey.io/commands/pubsub-numpat) for more details.
|
|
6794
7362
|
|
|
6795
7363
|
Returns:
|
|
6796
7364
|
int: The number of unique patterns.
|
|
@@ -6807,14 +7375,17 @@ class CoreCommands(Protocol):
|
|
|
6807
7375
|
"""
|
|
6808
7376
|
Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified channels.
|
|
6809
7377
|
|
|
6810
|
-
Note
|
|
6811
|
-
|
|
7378
|
+
Note:
|
|
7379
|
+
It is valid to call this command without channels. In this case, it will just return an empty map.
|
|
7380
|
+
|
|
7381
|
+
The command is routed to all nodes, and aggregates the response to a single map of the channels and their number
|
|
7382
|
+
of subscriptions.
|
|
6812
7383
|
|
|
6813
|
-
See https://valkey.io/commands/pubsub-numsub for more details.
|
|
7384
|
+
See [valkey.io](https://valkey.io/commands/pubsub-numsub) for more details.
|
|
6814
7385
|
|
|
6815
7386
|
Args:
|
|
6816
7387
|
channels (Optional[List[TEncodable]]): The list of channels to query for the number of subscribers.
|
|
6817
|
-
|
|
7388
|
+
If not provided, returns an empty map.
|
|
6818
7389
|
|
|
6819
7390
|
Returns:
|
|
6820
7391
|
Mapping[bytes, int]: A map where keys are the channel names and values are the number of subscribers.
|
|
@@ -6844,19 +7415,22 @@ class CoreCommands(Protocol):
|
|
|
6844
7415
|
) -> List[Optional[bytes]]:
|
|
6845
7416
|
"""
|
|
6846
7417
|
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
|
|
7418
|
+
The `sort` command can be used to sort elements based on different criteria and apply transformations on sorted
|
|
7419
|
+
elements.
|
|
6848
7420
|
This command is routed to primary nodes only.
|
|
6849
7421
|
To store the result into a new key, see `sort_store`.
|
|
6850
7422
|
|
|
6851
|
-
Note:
|
|
7423
|
+
Note:
|
|
7424
|
+
When in cluster mode, `key`, and any patterns specified in `by_pattern` or `get_patterns`
|
|
6852
7425
|
must map to the same hash slot. The use of `by_pattern` and `get_patterns` in cluster mode is supported
|
|
6853
7426
|
only since Valkey version 8.0.
|
|
6854
7427
|
|
|
6855
|
-
See https://valkey.io/commands/sort for more details.
|
|
7428
|
+
See [valkey.io](https://valkey.io/commands/sort) for more details.
|
|
6856
7429
|
|
|
6857
7430
|
Args:
|
|
6858
7431
|
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
|
|
7432
|
+
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the key
|
|
7433
|
+
themselves.
|
|
6860
7434
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6861
7435
|
from the key replaces the asterisk to create the key name. For example, if `key` contains IDs of objects,
|
|
6862
7436
|
`by_pattern` can be used to sort these IDs based on an attribute of the objects, like their weights or
|
|
@@ -6865,8 +7439,10 @@ class CoreCommands(Protocol):
|
|
|
6865
7439
|
keys `weight_<element>`.
|
|
6866
7440
|
If not provided, elements are sorted by their value.
|
|
6867
7441
|
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
|
-
|
|
7442
|
+
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
7443
|
+
more information.
|
|
7444
|
+
get_patterns (Optional[List[TEncodable]]): A pattern used to retrieve external keys' values, instead of the
|
|
7445
|
+
elements at `key`.
|
|
6870
7446
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6871
7447
|
from `key` replaces the asterisk to create the key name. This allows the sorted elements to be
|
|
6872
7448
|
transformed based on the related keys values. For example, if `key` contains IDs of users, `get_pattern`
|
|
@@ -6878,8 +7454,10 @@ class CoreCommands(Protocol):
|
|
|
6878
7454
|
Supported in cluster mode since Valkey version 8.0.
|
|
6879
7455
|
order (Optional[OrderBy]): Specifies the order to sort the elements.
|
|
6880
7456
|
Can be `OrderBy.ASC` (ascending) or `OrderBy.DESC` (descending).
|
|
6881
|
-
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
6882
|
-
|
|
7457
|
+
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7458
|
+
numerically.
|
|
7459
|
+
Use this when the list, set, or sorted set contains string values that cannot be converted into double
|
|
7460
|
+
precision floating point
|
|
6883
7461
|
|
|
6884
7462
|
Returns:
|
|
6885
7463
|
List[Optional[bytes]]: Returns a list of sorted elements.
|
|
@@ -6914,18 +7492,21 @@ class CoreCommands(Protocol):
|
|
|
6914
7492
|
) -> List[Optional[bytes]]:
|
|
6915
7493
|
"""
|
|
6916
7494
|
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
|
|
7495
|
+
The `sort_ro` command can be used to sort elements based on different criteria and apply transformations on
|
|
7496
|
+
sorted elements.
|
|
6918
7497
|
This command is routed depending on the client's `ReadFrom` strategy.
|
|
6919
7498
|
|
|
6920
|
-
See https://valkey.io/commands/sort for more details.
|
|
7499
|
+
See [valkey.io](https://valkey.io/commands/sort) for more details.
|
|
6921
7500
|
|
|
6922
|
-
Note:
|
|
7501
|
+
Note:
|
|
7502
|
+
When in cluster mode, `key`, and any patterns specified in `by_pattern` or `get_patterns`
|
|
6923
7503
|
must map to the same hash slot. The use of `by_pattern` and `get_patterns` in cluster mode is supported
|
|
6924
7504
|
only since Valkey version 8.0.
|
|
6925
7505
|
|
|
6926
7506
|
Args:
|
|
6927
7507
|
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
|
|
7508
|
+
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the
|
|
7509
|
+
key themselves.
|
|
6929
7510
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6930
7511
|
from the key replaces the asterisk to create the key name. For example, if `key` contains IDs of objects,
|
|
6931
7512
|
`by_pattern` can be used to sort these IDs based on an attribute of the objects, like their weights or
|
|
@@ -6934,8 +7515,10 @@ class CoreCommands(Protocol):
|
|
|
6934
7515
|
keys `weight_<element>`.
|
|
6935
7516
|
If not provided, elements are sorted by their value.
|
|
6936
7517
|
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
|
-
|
|
7518
|
+
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
7519
|
+
more information.
|
|
7520
|
+
get_patterns (Optional[List[TEncodable]]): A pattern used to retrieve external keys' values, instead of the
|
|
7521
|
+
elements at `key`.
|
|
6939
7522
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
6940
7523
|
from `key` replaces the asterisk to create the key name. This allows the sorted elements to be
|
|
6941
7524
|
transformed based on the related keys values. For example, if `key` contains IDs of users, `get_pattern`
|
|
@@ -6947,8 +7530,10 @@ class CoreCommands(Protocol):
|
|
|
6947
7530
|
Supported in cluster mode since Valkey version 8.0.
|
|
6948
7531
|
order (Optional[OrderBy]): Specifies the order to sort the elements.
|
|
6949
7532
|
Can be `OrderBy.ASC` (ascending) or `OrderBy.DESC` (descending).
|
|
6950
|
-
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
6951
|
-
|
|
7533
|
+
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7534
|
+
numerically.
|
|
7535
|
+
Use this when the list, set, or sorted set contains string values that cannot be converted into double
|
|
7536
|
+
precision floating point
|
|
6952
7537
|
|
|
6953
7538
|
Returns:
|
|
6954
7539
|
List[Optional[bytes]]: Returns a list of sorted elements.
|
|
@@ -6986,19 +7571,22 @@ class CoreCommands(Protocol):
|
|
|
6986
7571
|
) -> int:
|
|
6987
7572
|
"""
|
|
6988
7573
|
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,
|
|
7574
|
+
The `sort` command can be used to sort elements based on different criteria, apply transformations on sorted elements,
|
|
7575
|
+
and store the result in a new key.
|
|
6990
7576
|
To get the sort result without storing it into a key, see `sort`.
|
|
6991
7577
|
|
|
6992
|
-
See https://valkey.io/commands/sort for more details.
|
|
7578
|
+
See [valkey.io](https://valkey.io/commands/sort) for more details.
|
|
6993
7579
|
|
|
6994
|
-
Note:
|
|
7580
|
+
Note:
|
|
7581
|
+
When in cluster mode, `key`, `destination`, and any patterns specified in `by_pattern` or `get_patterns`
|
|
6995
7582
|
must map to the same hash slot. The use of `by_pattern` and `get_patterns` in cluster mode is supported
|
|
6996
7583
|
only since Valkey version 8.0.
|
|
6997
7584
|
|
|
6998
7585
|
Args:
|
|
6999
7586
|
key (TEncodable): The key of the list, set, or sorted set to be sorted.
|
|
7000
7587
|
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
|
|
7588
|
+
by_pattern (Optional[TEncodable]): A pattern to sort by external keys instead of by the elements stored at the key
|
|
7589
|
+
themselves.
|
|
7002
7590
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
7003
7591
|
from the key replaces the asterisk to create the key name. For example, if `key` contains IDs of objects,
|
|
7004
7592
|
`by_pattern` can be used to sort these IDs based on an attribute of the objects, like their weights or
|
|
@@ -7007,8 +7595,10 @@ class CoreCommands(Protocol):
|
|
|
7007
7595
|
keys `weight_<element>`.
|
|
7008
7596
|
If not provided, elements are sorted by their value.
|
|
7009
7597
|
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
|
-
|
|
7598
|
+
limit (Optional[Limit]): Limiting the range of the query by setting offset and result count. See `Limit` class for
|
|
7599
|
+
more information.
|
|
7600
|
+
get_patterns (Optional[List[TEncodable]]): A pattern used to retrieve external keys' values, instead of the
|
|
7601
|
+
elements at `key`.
|
|
7012
7602
|
The pattern should contain an asterisk (*) as a placeholder for the element values, where the value
|
|
7013
7603
|
from `key` replaces the asterisk to create the key name. This allows the sorted elements to be
|
|
7014
7604
|
transformed based on the related keys values. For example, if `key` contains IDs of users, `get_pattern`
|
|
@@ -7020,8 +7610,10 @@ class CoreCommands(Protocol):
|
|
|
7020
7610
|
Supported in cluster mode since Valkey version 8.0.
|
|
7021
7611
|
order (Optional[OrderBy]): Specifies the order to sort the elements.
|
|
7022
7612
|
Can be `OrderBy.ASC` (ascending) or `OrderBy.DESC` (descending).
|
|
7023
|
-
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7024
|
-
|
|
7613
|
+
alpha (Optional[bool]): When `True`, sorts elements lexicographically. When `False` (default), sorts elements
|
|
7614
|
+
numerically.
|
|
7615
|
+
Use this when the list, set, or sorted set contains string values that cannot be converted into double
|
|
7616
|
+
precision floating point
|
|
7025
7617
|
|
|
7026
7618
|
Returns:
|
|
7027
7619
|
int: The number of elements in the sorted key stored at `store`.
|