valkey-glide 2.0.0rc2__cp312-cp312-macosx_11_0_arm64.whl → 2.2.0rc2__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.
- glide/__init__.py +160 -106
- glide/async_commands/cluster_commands.py +108 -105
- glide/async_commands/core.py +637 -444
- glide/async_commands/{server_modules/ft.py → ft.py} +8 -7
- glide/async_commands/{server_modules/glide_json.py → glide_json.py} +15 -92
- glide/async_commands/standalone_commands.py +27 -58
- glide/glide.cpython-312-darwin.so +0 -0
- glide/glide.pyi +26 -1
- glide/glide_client.py +270 -126
- glide/logger.py +33 -21
- glide/opentelemetry.py +185 -0
- glide_shared/__init__.py +330 -0
- glide_shared/commands/__init__.py +0 -0
- {glide/async_commands → glide_shared/commands}/batch.py +476 -64
- glide_shared/commands/batch_options.py +261 -0
- glide_shared/commands/core_options.py +407 -0
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +3 -3
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +4 -2
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +4 -4
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +4 -2
- {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +4 -4
- glide_shared/commands/server_modules/json_options.py +93 -0
- {glide/async_commands → glide_shared/commands}/sorted_set.py +2 -2
- {glide/async_commands → glide_shared/commands}/stream.py +1 -1
- {glide → glide_shared}/config.py +386 -61
- {glide → glide_shared}/constants.py +3 -3
- {glide → glide_shared}/exceptions.py +27 -1
- glide_shared/protobuf/command_request_pb2.py +56 -0
- glide_shared/protobuf/connection_request_pb2.py +56 -0
- {glide → glide_shared}/protobuf/response_pb2.py +6 -6
- {glide → glide_shared}/routes.py +54 -15
- valkey_glide-2.2.0rc2.dist-info/METADATA +210 -0
- valkey_glide-2.2.0rc2.dist-info/RECORD +40 -0
- glide/protobuf/command_request_pb2.py +0 -54
- glide/protobuf/command_request_pb2.pyi +0 -1187
- glide/protobuf/connection_request_pb2.py +0 -54
- glide/protobuf/connection_request_pb2.pyi +0 -320
- glide/protobuf/response_pb2.pyi +0 -100
- valkey_glide-2.0.0rc2.dist-info/METADATA +0 -127
- valkey_glide-2.0.0rc2.dist-info/RECORD +0 -37
- {glide/async_commands → glide_shared/commands}/bitmap.py +0 -0
- {glide/async_commands → glide_shared/commands}/command_args.py +0 -0
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
- {glide → glide_shared}/protobuf_codec.py +0 -0
- {valkey_glide-2.0.0rc2.dist-info → valkey_glide-2.2.0rc2.dist-info}/WHEEL +0 -0
glide/async_commands/core.py
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
# Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
|
|
2
|
-
from
|
|
3
|
-
from datetime import datetime, timedelta
|
|
4
|
-
from enum import Enum
|
|
5
|
-
from typing import (
|
|
6
|
-
Dict,
|
|
7
|
-
List,
|
|
8
|
-
Mapping,
|
|
9
|
-
Optional,
|
|
10
|
-
Protocol,
|
|
11
|
-
Set,
|
|
12
|
-
Tuple,
|
|
13
|
-
Type,
|
|
14
|
-
Union,
|
|
15
|
-
cast,
|
|
16
|
-
get_args,
|
|
17
|
-
)
|
|
2
|
+
from typing import Dict, List, Mapping, Optional, Protocol, Set, Tuple, Union, cast
|
|
18
3
|
|
|
19
|
-
from glide.
|
|
4
|
+
from glide.glide import ClusterScanCursor
|
|
5
|
+
from glide_shared.commands.bitmap import (
|
|
20
6
|
BitFieldGet,
|
|
21
7
|
BitFieldSubCommands,
|
|
22
8
|
BitwiseOperation,
|
|
@@ -24,8 +10,20 @@ from glide.async_commands.bitmap import (
|
|
|
24
10
|
_create_bitfield_args,
|
|
25
11
|
_create_bitfield_read_only_args,
|
|
26
12
|
)
|
|
27
|
-
from
|
|
28
|
-
from
|
|
13
|
+
from glide_shared.commands.command_args import Limit, ListDirection, ObjectType, OrderBy
|
|
14
|
+
from glide_shared.commands.core_options import (
|
|
15
|
+
ConditionalChange,
|
|
16
|
+
ExpireOptions,
|
|
17
|
+
ExpiryGetEx,
|
|
18
|
+
ExpirySet,
|
|
19
|
+
HashFieldConditionalChange,
|
|
20
|
+
InsertPosition,
|
|
21
|
+
OnlyIfEqual,
|
|
22
|
+
PubSubMsg,
|
|
23
|
+
UpdateOptions,
|
|
24
|
+
_build_sort_args,
|
|
25
|
+
)
|
|
26
|
+
from glide_shared.commands.sorted_set import (
|
|
29
27
|
AggregationType,
|
|
30
28
|
GeoSearchByBox,
|
|
31
29
|
GeoSearchByRadius,
|
|
@@ -43,7 +41,7 @@ from glide.async_commands.sorted_set import (
|
|
|
43
41
|
_create_zinter_zunion_cmd_args,
|
|
44
42
|
_create_zrange_args,
|
|
45
43
|
)
|
|
46
|
-
from
|
|
44
|
+
from glide_shared.commands.stream import (
|
|
47
45
|
StreamAddOptions,
|
|
48
46
|
StreamClaimOptions,
|
|
49
47
|
StreamGroupOptions,
|
|
@@ -54,388 +52,16 @@ from glide.async_commands.stream import (
|
|
|
54
52
|
StreamTrimOptions,
|
|
55
53
|
_create_xpending_range_args,
|
|
56
54
|
)
|
|
57
|
-
from
|
|
55
|
+
from glide_shared.constants import (
|
|
58
56
|
TOK,
|
|
59
57
|
TEncodable,
|
|
60
58
|
TResult,
|
|
61
59
|
TXInfoStreamFullResponse,
|
|
62
60
|
TXInfoStreamResponse,
|
|
63
61
|
)
|
|
64
|
-
from
|
|
65
|
-
from
|
|
66
|
-
|
|
67
|
-
from ..glide import ClusterScanCursor
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class ConditionalChange(Enum):
|
|
71
|
-
"""
|
|
72
|
-
A condition to the `SET`, `ZADD` and `GEOADD` commands.
|
|
73
|
-
"""
|
|
74
|
-
|
|
75
|
-
ONLY_IF_EXISTS = "XX"
|
|
76
|
-
""" Only update key / elements that already exist. Equivalent to `XX` in the Valkey API. """
|
|
77
|
-
|
|
78
|
-
ONLY_IF_DOES_NOT_EXIST = "NX"
|
|
79
|
-
""" Only set key / add elements that does not already exist. Equivalent to `NX` in the Valkey API. """
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@dataclass
|
|
83
|
-
class OnlyIfEqual:
|
|
84
|
-
"""
|
|
85
|
-
Change condition to the `SET` command,
|
|
86
|
-
For additional conditonal options see ConditionalChange
|
|
87
|
-
|
|
88
|
-
- comparison_value - value to compare to the current value of a key.
|
|
89
|
-
|
|
90
|
-
If comparison_value is equal to the key, it will overwrite the value of key to the new provided value
|
|
91
|
-
Equivalent to the IFEQ comparison-value in the Valkey API
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
comparison_value: TEncodable
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
class ExpiryType(Enum):
|
|
98
|
-
"""
|
|
99
|
-
SET option: The type of the expiry.
|
|
100
|
-
"""
|
|
101
|
-
|
|
102
|
-
SEC = 0, Union[int, timedelta]
|
|
103
|
-
"""
|
|
104
|
-
Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API.
|
|
105
|
-
"""
|
|
106
|
-
|
|
107
|
-
MILLSEC = 1, Union[int, timedelta]
|
|
108
|
-
"""
|
|
109
|
-
Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API.
|
|
110
|
-
"""
|
|
111
|
-
|
|
112
|
-
UNIX_SEC = 2, Union[int, datetime]
|
|
113
|
-
"""
|
|
114
|
-
Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API.
|
|
115
|
-
"""
|
|
116
|
-
|
|
117
|
-
UNIX_MILLSEC = 3, Union[int, datetime]
|
|
118
|
-
"""
|
|
119
|
-
Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API.
|
|
120
|
-
"""
|
|
121
|
-
|
|
122
|
-
KEEP_TTL = 4, Type[None]
|
|
123
|
-
"""
|
|
124
|
-
Retain the time to live associated with the key. Equivalent to `KEEPTTL` in the Valkey API.
|
|
125
|
-
"""
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
class ExpiryTypeGetEx(Enum):
|
|
129
|
-
"""
|
|
130
|
-
GetEx option: The type of the expiry.
|
|
131
|
-
"""
|
|
132
|
-
|
|
133
|
-
SEC = 0, Union[int, timedelta]
|
|
134
|
-
""" Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API. """
|
|
135
|
-
|
|
136
|
-
MILLSEC = 1, Union[int, timedelta]
|
|
137
|
-
""" Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API. """
|
|
138
|
-
|
|
139
|
-
UNIX_SEC = 2, Union[int, datetime]
|
|
140
|
-
""" Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API. """
|
|
141
|
-
|
|
142
|
-
UNIX_MILLSEC = 3, Union[int, datetime]
|
|
143
|
-
""" Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API. """
|
|
144
|
-
|
|
145
|
-
PERSIST = 4, Type[None]
|
|
146
|
-
""" Remove the time to live associated with the key. Equivalent to `PERSIST` in the Valkey API. """
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
class InfoSection(Enum):
|
|
150
|
-
"""
|
|
151
|
-
INFO option: a specific section of information:
|
|
152
|
-
|
|
153
|
-
When no parameter is provided, the default option is assumed.
|
|
154
|
-
"""
|
|
155
|
-
|
|
156
|
-
SERVER = "server"
|
|
157
|
-
""" General information about the server """
|
|
158
|
-
|
|
159
|
-
CLIENTS = "clients"
|
|
160
|
-
""" Client connections section """
|
|
161
|
-
|
|
162
|
-
MEMORY = "memory"
|
|
163
|
-
""" Memory consumption related information """
|
|
164
|
-
|
|
165
|
-
PERSISTENCE = "persistence"
|
|
166
|
-
""" RDB and AOF related information """
|
|
167
|
-
|
|
168
|
-
STATS = "stats"
|
|
169
|
-
""" General statistics """
|
|
170
|
-
|
|
171
|
-
REPLICATION = "replication"
|
|
172
|
-
""" Master/replica replication information """
|
|
173
|
-
|
|
174
|
-
CPU = "cpu"
|
|
175
|
-
""" CPU consumption statistics """
|
|
176
|
-
|
|
177
|
-
COMMAND_STATS = "commandstats"
|
|
178
|
-
""" Valkey command statistics """
|
|
179
|
-
|
|
180
|
-
LATENCY_STATS = "latencystats"
|
|
181
|
-
""" Valkey command latency percentile distribution statistics """
|
|
182
|
-
|
|
183
|
-
SENTINEL = "sentinel"
|
|
184
|
-
""" Valkey Sentinel section (only applicable to Sentinel instances) """
|
|
185
|
-
|
|
186
|
-
CLUSTER = "cluster"
|
|
187
|
-
""" Valkey Cluster section """
|
|
188
|
-
|
|
189
|
-
MODULES = "modules"
|
|
190
|
-
""" Modules section """
|
|
191
|
-
|
|
192
|
-
KEYSPACE = "keyspace"
|
|
193
|
-
""" Database related statistics """
|
|
194
|
-
|
|
195
|
-
ERROR_STATS = "errorstats"
|
|
196
|
-
""" Valkey error statistics """
|
|
197
|
-
|
|
198
|
-
ALL = "all"
|
|
199
|
-
""" Return all sections (excluding module generated ones) """
|
|
200
|
-
|
|
201
|
-
DEFAULT = "default"
|
|
202
|
-
""" Return only the default set of sections """
|
|
203
|
-
|
|
204
|
-
EVERYTHING = "everything"
|
|
205
|
-
""" Includes all and modules """
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
class ExpireOptions(Enum):
|
|
209
|
-
"""
|
|
210
|
-
EXPIRE option: options for setting key expiry.
|
|
211
|
-
"""
|
|
212
|
-
|
|
213
|
-
HasNoExpiry = "NX"
|
|
214
|
-
""" Set expiry only when the key has no expiry (Equivalent to "NX" in Valkey). """
|
|
215
|
-
|
|
216
|
-
HasExistingExpiry = "XX"
|
|
217
|
-
""" Set expiry only when the key has an existing expiry (Equivalent to "XX" in Valkey). """
|
|
218
|
-
|
|
219
|
-
NewExpiryGreaterThanCurrent = "GT"
|
|
220
|
-
"""
|
|
221
|
-
Set expiry only when the new expiry is greater than the current one (Equivalent to "GT" in Valkey).
|
|
222
|
-
"""
|
|
223
|
-
|
|
224
|
-
NewExpiryLessThanCurrent = "LT"
|
|
225
|
-
"""
|
|
226
|
-
Set expiry only when the new expiry is less than the current one (Equivalent to "LT" in Valkey).
|
|
227
|
-
"""
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
class UpdateOptions(Enum):
|
|
231
|
-
"""
|
|
232
|
-
Options for updating elements of a sorted set key.
|
|
233
|
-
"""
|
|
234
|
-
|
|
235
|
-
LESS_THAN = "LT"
|
|
236
|
-
""" Only update existing elements if the new score is less than the current score. """
|
|
237
|
-
|
|
238
|
-
GREATER_THAN = "GT"
|
|
239
|
-
""" Only update existing elements if the new score is greater than the current score. """
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
class ExpirySet:
|
|
243
|
-
"""
|
|
244
|
-
SET option: Represents the expiry type and value to be executed with "SET" command.
|
|
245
|
-
|
|
246
|
-
Attributes:
|
|
247
|
-
cmd_arg (str): The expiry type.
|
|
248
|
-
value (str): The value for the expiry type.
|
|
249
|
-
"""
|
|
250
|
-
|
|
251
|
-
def __init__(
|
|
252
|
-
self,
|
|
253
|
-
expiry_type: ExpiryType,
|
|
254
|
-
value: Optional[Union[int, datetime, timedelta]],
|
|
255
|
-
) -> None:
|
|
256
|
-
self.set_expiry_type_and_value(expiry_type, value)
|
|
257
|
-
|
|
258
|
-
def __eq__(self, other: "object") -> bool:
|
|
259
|
-
if not isinstance(other, ExpirySet):
|
|
260
|
-
return NotImplemented
|
|
261
|
-
return self.expiry_type == other.expiry_type and self.value == other.value
|
|
262
|
-
|
|
263
|
-
def set_expiry_type_and_value(
|
|
264
|
-
self, expiry_type: ExpiryType, value: Optional[Union[int, datetime, timedelta]]
|
|
265
|
-
):
|
|
266
|
-
"""
|
|
267
|
-
Args:
|
|
268
|
-
expiry_type (ExpiryType): The expiry type.
|
|
269
|
-
value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
|
|
270
|
-
determines the type of expiration value:
|
|
271
|
-
|
|
272
|
-
- SEC: Union[int, timedelta]
|
|
273
|
-
- MILLSEC: Union[int, timedelta]
|
|
274
|
-
- UNIX_SEC: Union[int, datetime]
|
|
275
|
-
- UNIX_MILLSEC: Union[int, datetime]
|
|
276
|
-
- KEEP_TTL: Type[None]
|
|
277
|
-
"""
|
|
278
|
-
if not isinstance(value, get_args(expiry_type.value[1])):
|
|
279
|
-
raise ValueError(
|
|
280
|
-
f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
|
|
281
|
-
)
|
|
282
|
-
self.expiry_type = expiry_type
|
|
283
|
-
if self.expiry_type == ExpiryType.SEC:
|
|
284
|
-
self.cmd_arg = "EX"
|
|
285
|
-
if isinstance(value, timedelta):
|
|
286
|
-
value = int(value.total_seconds())
|
|
287
|
-
elif self.expiry_type == ExpiryType.MILLSEC:
|
|
288
|
-
self.cmd_arg = "PX"
|
|
289
|
-
if isinstance(value, timedelta):
|
|
290
|
-
value = int(value.total_seconds() * 1000)
|
|
291
|
-
elif self.expiry_type == ExpiryType.UNIX_SEC:
|
|
292
|
-
self.cmd_arg = "EXAT"
|
|
293
|
-
if isinstance(value, datetime):
|
|
294
|
-
value = int(value.timestamp())
|
|
295
|
-
elif self.expiry_type == ExpiryType.UNIX_MILLSEC:
|
|
296
|
-
self.cmd_arg = "PXAT"
|
|
297
|
-
if isinstance(value, datetime):
|
|
298
|
-
value = int(value.timestamp() * 1000)
|
|
299
|
-
elif self.expiry_type == ExpiryType.KEEP_TTL:
|
|
300
|
-
self.cmd_arg = "KEEPTTL"
|
|
301
|
-
self.value = str(value) if value else None
|
|
302
|
-
|
|
303
|
-
def get_cmd_args(self) -> List[str]:
|
|
304
|
-
return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
class ExpiryGetEx:
|
|
308
|
-
"""
|
|
309
|
-
GetEx option: Represents the expiry type and value to be executed with "GetEx" command.
|
|
310
|
-
|
|
311
|
-
Attributes:
|
|
312
|
-
cmd_arg (str): The expiry type.
|
|
313
|
-
value (str): The value for the expiry type.
|
|
314
|
-
"""
|
|
315
|
-
|
|
316
|
-
def __init__(
|
|
317
|
-
self,
|
|
318
|
-
expiry_type: ExpiryTypeGetEx,
|
|
319
|
-
value: Optional[Union[int, datetime, timedelta]],
|
|
320
|
-
) -> None:
|
|
321
|
-
self.set_expiry_type_and_value(expiry_type, value)
|
|
322
|
-
|
|
323
|
-
def set_expiry_type_and_value(
|
|
324
|
-
self,
|
|
325
|
-
expiry_type: ExpiryTypeGetEx,
|
|
326
|
-
value: Optional[Union[int, datetime, timedelta]],
|
|
327
|
-
):
|
|
328
|
-
"""
|
|
329
|
-
Args:
|
|
330
|
-
expiry_type (ExpiryType): The expiry type.
|
|
331
|
-
value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
|
|
332
|
-
determines the type of expiration value:
|
|
333
|
-
|
|
334
|
-
- SEC: Union[int, timedelta]
|
|
335
|
-
- MILLSEC: Union[int, timedelta]
|
|
336
|
-
- UNIX_SEC: Union[int, datetime]
|
|
337
|
-
- UNIX_MILLSEC: Union[int, datetime]
|
|
338
|
-
- PERSIST: Type[None]
|
|
339
|
-
"""
|
|
340
|
-
if not isinstance(value, get_args(expiry_type.value[1])):
|
|
341
|
-
raise ValueError(
|
|
342
|
-
f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
|
|
343
|
-
)
|
|
344
|
-
self.expiry_type = expiry_type
|
|
345
|
-
if self.expiry_type == ExpiryTypeGetEx.SEC:
|
|
346
|
-
self.cmd_arg = "EX"
|
|
347
|
-
if isinstance(value, timedelta):
|
|
348
|
-
value = int(value.total_seconds())
|
|
349
|
-
elif self.expiry_type == ExpiryTypeGetEx.MILLSEC:
|
|
350
|
-
self.cmd_arg = "PX"
|
|
351
|
-
if isinstance(value, timedelta):
|
|
352
|
-
value = int(value.total_seconds() * 1000)
|
|
353
|
-
elif self.expiry_type == ExpiryTypeGetEx.UNIX_SEC:
|
|
354
|
-
self.cmd_arg = "EXAT"
|
|
355
|
-
if isinstance(value, datetime):
|
|
356
|
-
value = int(value.timestamp())
|
|
357
|
-
elif self.expiry_type == ExpiryTypeGetEx.UNIX_MILLSEC:
|
|
358
|
-
self.cmd_arg = "PXAT"
|
|
359
|
-
if isinstance(value, datetime):
|
|
360
|
-
value = int(value.timestamp() * 1000)
|
|
361
|
-
elif self.expiry_type == ExpiryTypeGetEx.PERSIST:
|
|
362
|
-
self.cmd_arg = "PERSIST"
|
|
363
|
-
self.value = str(value) if value else None
|
|
364
|
-
|
|
365
|
-
def get_cmd_args(self) -> List[str]:
|
|
366
|
-
return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
class InsertPosition(Enum):
|
|
370
|
-
BEFORE = "BEFORE"
|
|
371
|
-
AFTER = "AFTER"
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
class FlushMode(Enum):
|
|
375
|
-
"""
|
|
376
|
-
Defines flushing mode for:
|
|
377
|
-
|
|
378
|
-
`FLUSHALL` command and `FUNCTION FLUSH` command.
|
|
379
|
-
|
|
380
|
-
See [FLUSHAL](https://valkey.io/commands/flushall/) and [FUNCTION-FLUSH](https://valkey.io/commands/function-flush/)
|
|
381
|
-
for details
|
|
382
|
-
|
|
383
|
-
SYNC was introduced in version 6.2.0.
|
|
384
|
-
"""
|
|
385
|
-
|
|
386
|
-
ASYNC = "ASYNC"
|
|
387
|
-
SYNC = "SYNC"
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
class FunctionRestorePolicy(Enum):
|
|
391
|
-
"""
|
|
392
|
-
Options for the FUNCTION RESTORE command.
|
|
393
|
-
"""
|
|
394
|
-
|
|
395
|
-
APPEND = "APPEND"
|
|
396
|
-
""" Appends the restored libraries to the existing libraries and aborts on collision. This is the default policy. """
|
|
397
|
-
|
|
398
|
-
FLUSH = "FLUSH"
|
|
399
|
-
""" Deletes all existing libraries before restoring the payload. """
|
|
400
|
-
|
|
401
|
-
REPLACE = "REPLACE"
|
|
402
|
-
"""
|
|
403
|
-
Appends the restored libraries to the existing libraries, replacing any existing ones in case
|
|
404
|
-
of name collisions. Note that this policy doesn't prevent function name collisions, only libraries.
|
|
405
|
-
"""
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
def _build_sort_args(
|
|
409
|
-
key: TEncodable,
|
|
410
|
-
by_pattern: Optional[TEncodable] = None,
|
|
411
|
-
limit: Optional[Limit] = None,
|
|
412
|
-
get_patterns: Optional[List[TEncodable]] = None,
|
|
413
|
-
order: Optional[OrderBy] = None,
|
|
414
|
-
alpha: Optional[bool] = None,
|
|
415
|
-
store: Optional[TEncodable] = None,
|
|
416
|
-
) -> List[TEncodable]:
|
|
417
|
-
args = [key]
|
|
418
|
-
|
|
419
|
-
if by_pattern:
|
|
420
|
-
args.extend(["BY", by_pattern])
|
|
421
|
-
|
|
422
|
-
if limit:
|
|
423
|
-
args.extend(["LIMIT", str(limit.offset), str(limit.count)])
|
|
424
|
-
|
|
425
|
-
if get_patterns:
|
|
426
|
-
for pattern in get_patterns:
|
|
427
|
-
args.extend(["GET", pattern])
|
|
428
|
-
|
|
429
|
-
if order:
|
|
430
|
-
args.append(order.value)
|
|
431
|
-
|
|
432
|
-
if alpha:
|
|
433
|
-
args.append("ALPHA")
|
|
434
|
-
|
|
435
|
-
if store:
|
|
436
|
-
args.extend(["STORE", store])
|
|
437
|
-
|
|
438
|
-
return args
|
|
62
|
+
from glide_shared.exceptions import RequestError
|
|
63
|
+
from glide_shared.protobuf.command_request_pb2 import RequestType
|
|
64
|
+
from glide_shared.routes import Route
|
|
439
65
|
|
|
440
66
|
|
|
441
67
|
class CoreCommands(Protocol):
|
|
@@ -513,6 +139,27 @@ class CoreCommands(Protocol):
|
|
|
513
139
|
TOK, await self._update_connection_password(password, immediate_auth)
|
|
514
140
|
)
|
|
515
141
|
|
|
142
|
+
async def _refresh_iam_token(self) -> TResult: ...
|
|
143
|
+
|
|
144
|
+
async def refresh_iam_token(self) -> TOK:
|
|
145
|
+
"""
|
|
146
|
+
Manually refresh the IAM token for the current connection.
|
|
147
|
+
|
|
148
|
+
This method is only available if the client was created with IAM authentication.
|
|
149
|
+
It triggers an immediate refresh of the IAM token and updates the connection.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
TOK: A simple OK response on success.
|
|
153
|
+
|
|
154
|
+
Raises:
|
|
155
|
+
ConfigurationError: If the client is not using IAM authentication.
|
|
156
|
+
|
|
157
|
+
Example:
|
|
158
|
+
>>> await client.refresh_iam_token()
|
|
159
|
+
'OK'
|
|
160
|
+
"""
|
|
161
|
+
return cast(TOK, await self._refresh_iam_token())
|
|
162
|
+
|
|
516
163
|
async def set(
|
|
517
164
|
self,
|
|
518
165
|
key: TEncodable,
|
|
@@ -593,7 +240,7 @@ class CoreCommands(Protocol):
|
|
|
593
240
|
|
|
594
241
|
async def get(self, key: TEncodable) -> Optional[bytes]:
|
|
595
242
|
"""
|
|
596
|
-
Get the value associated with the given key, or null if no such
|
|
243
|
+
Get the value associated with the given key, or null if no such key exists.
|
|
597
244
|
|
|
598
245
|
See [valkey.io](https://valkey.io/commands/get/) for details.
|
|
599
246
|
|
|
@@ -804,6 +451,34 @@ class CoreCommands(Protocol):
|
|
|
804
451
|
"""
|
|
805
452
|
return cast(int, await self._execute_command(RequestType.Del, keys))
|
|
806
453
|
|
|
454
|
+
async def move(self, key: TEncodable, db_index: int) -> bool:
|
|
455
|
+
"""
|
|
456
|
+
Move key from the currently selected database to the specified destination database.
|
|
457
|
+
|
|
458
|
+
Note:
|
|
459
|
+
For cluster mode move command is supported since Valkey 9.0.0
|
|
460
|
+
|
|
461
|
+
See [valkey.io](https://valkey.io/commands/move/) for more details.
|
|
462
|
+
|
|
463
|
+
Args:
|
|
464
|
+
key (TEncodable): The key to move.
|
|
465
|
+
db_index (int): The destination database number.
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
bool: True if the key was moved successfully, False if the key does not exist
|
|
469
|
+
or was already present in the destination database.
|
|
470
|
+
|
|
471
|
+
Examples:
|
|
472
|
+
>>> await client.move("some_key", 1)
|
|
473
|
+
True # The key was successfully moved to database 1
|
|
474
|
+
>>> await client.move("nonexistent_key", 1)
|
|
475
|
+
False # The key does not exist
|
|
476
|
+
"""
|
|
477
|
+
return cast(
|
|
478
|
+
bool,
|
|
479
|
+
await self._execute_command(RequestType.Move, [key, str(db_index)]),
|
|
480
|
+
)
|
|
481
|
+
|
|
807
482
|
async def incr(self, key: TEncodable) -> int:
|
|
808
483
|
"""
|
|
809
484
|
Increments the number stored at `key` by one. If the key does not exist, it is set to 0 before performing the
|
|
@@ -1477,6 +1152,519 @@ class CoreCommands(Protocol):
|
|
|
1477
1152
|
await self._execute_command(RequestType.HStrlen, [key, field]),
|
|
1478
1153
|
)
|
|
1479
1154
|
|
|
1155
|
+
async def httl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
|
|
1156
|
+
"""
|
|
1157
|
+
Returns the remaining time to live (in seconds) of hash key's field(s) that have an associated expiration.
|
|
1158
|
+
|
|
1159
|
+
See [valkey.io](https://valkey.io/commands/httl/) for more details.
|
|
1160
|
+
|
|
1161
|
+
Args:
|
|
1162
|
+
key (TEncodable): The key of the hash.
|
|
1163
|
+
fields (List[TEncodable]): The list of fields to get TTL for.
|
|
1164
|
+
|
|
1165
|
+
Returns:
|
|
1166
|
+
List[int]: A list of TTL values for each field:
|
|
1167
|
+
- Positive integer: remaining TTL in seconds
|
|
1168
|
+
- `-1`: field exists but has no expiration
|
|
1169
|
+
- `-2`: field does not exist or key does not exist
|
|
1170
|
+
|
|
1171
|
+
Examples:
|
|
1172
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
|
|
1173
|
+
>>> await client.httl("my_hash", ["field1", "field2", "non_existent_field"])
|
|
1174
|
+
[9, 9, -2] # field1 and field2 have ~9 seconds left, non_existent_field doesn't exist
|
|
1175
|
+
|
|
1176
|
+
Since: Valkey 9.0.0
|
|
1177
|
+
"""
|
|
1178
|
+
return cast(
|
|
1179
|
+
List[int],
|
|
1180
|
+
await self._execute_command(
|
|
1181
|
+
RequestType.HTtl, [key, "FIELDS", str(len(fields))] + fields
|
|
1182
|
+
),
|
|
1183
|
+
)
|
|
1184
|
+
|
|
1185
|
+
async def hpttl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
|
|
1186
|
+
"""
|
|
1187
|
+
Returns the remaining time to live (in milliseconds) of hash key's field(s) that have an associated expiration.
|
|
1188
|
+
|
|
1189
|
+
See [valkey.io](https://valkey.io/commands/hpttl/) for more details.
|
|
1190
|
+
|
|
1191
|
+
Args:
|
|
1192
|
+
key (TEncodable): The key of the hash.
|
|
1193
|
+
fields (List[TEncodable]): The list of fields to get TTL for.
|
|
1194
|
+
|
|
1195
|
+
Returns:
|
|
1196
|
+
List[int]: A list of TTL values for each field:
|
|
1197
|
+
- Positive integer: remaining TTL in milliseconds
|
|
1198
|
+
- `-1`: field exists but has no expiration
|
|
1199
|
+
- `-2`: field does not exist or key does not exist
|
|
1200
|
+
|
|
1201
|
+
Examples:
|
|
1202
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
|
|
1203
|
+
>>> await client.hpttl("my_hash", ["field1", "field2", "non_existent_field"])
|
|
1204
|
+
[9500, 9500, -2] # field1 and field2 have ~9500 milliseconds left, non_existent_field doesn't exist
|
|
1205
|
+
|
|
1206
|
+
Since: Valkey 9.0.0
|
|
1207
|
+
"""
|
|
1208
|
+
return cast(
|
|
1209
|
+
List[int],
|
|
1210
|
+
await self._execute_command(
|
|
1211
|
+
RequestType.HPTtl, [key, "FIELDS", str(len(fields))] + fields
|
|
1212
|
+
),
|
|
1213
|
+
)
|
|
1214
|
+
|
|
1215
|
+
async def hexpiretime(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
|
|
1216
|
+
"""
|
|
1217
|
+
Returns the expiration Unix timestamp (in seconds) of hash key's field(s) that have an associated expiration.
|
|
1218
|
+
|
|
1219
|
+
See [valkey.io](https://valkey.io/commands/hexpiretime/) for more details.
|
|
1220
|
+
|
|
1221
|
+
Args:
|
|
1222
|
+
key (TEncodable): The key of the hash.
|
|
1223
|
+
fields (List[TEncodable]): The list of fields to get expiration timestamps for.
|
|
1224
|
+
|
|
1225
|
+
Returns:
|
|
1226
|
+
List[int]: A list of expiration timestamps for each field:
|
|
1227
|
+
- Positive integer: absolute expiration timestamp in seconds (Unix timestamp)
|
|
1228
|
+
- `-1`: field exists but has no expiration
|
|
1229
|
+
- `-2`: field does not exist or key does not exist
|
|
1230
|
+
|
|
1231
|
+
Examples:
|
|
1232
|
+
>>> import time
|
|
1233
|
+
>>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
|
|
1234
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_SEC, future_timestamp))
|
|
1235
|
+
>>> await client.hexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
|
|
1236
|
+
[future_timestamp, future_timestamp, -2] # field1 and field2 expire at future_timestamp, non_existent_field doesn't exist
|
|
1237
|
+
|
|
1238
|
+
Since: Valkey 9.0.0
|
|
1239
|
+
"""
|
|
1240
|
+
return cast(
|
|
1241
|
+
List[int],
|
|
1242
|
+
await self._execute_command(
|
|
1243
|
+
RequestType.HExpireTime, [key, "FIELDS", str(len(fields))] + fields
|
|
1244
|
+
),
|
|
1245
|
+
)
|
|
1246
|
+
|
|
1247
|
+
async def hpexpiretime(
|
|
1248
|
+
self, key: TEncodable, fields: List[TEncodable]
|
|
1249
|
+
) -> List[int]:
|
|
1250
|
+
"""
|
|
1251
|
+
Returns the expiration Unix timestamp (in milliseconds) of hash key's field(s) that have an associated expiration.
|
|
1252
|
+
|
|
1253
|
+
See [valkey.io](https://valkey.io/commands/hpexpiretime/) for more details.
|
|
1254
|
+
|
|
1255
|
+
Args:
|
|
1256
|
+
key (TEncodable): The key of the hash.
|
|
1257
|
+
fields (List[TEncodable]): The list of fields to get expiration timestamps for.
|
|
1258
|
+
|
|
1259
|
+
Returns:
|
|
1260
|
+
List[int]: A list of expiration timestamps for each field:
|
|
1261
|
+
- Positive integer: absolute expiration timestamp in milliseconds (Unix timestamp in ms)
|
|
1262
|
+
- `-1`: field exists but has no expiration
|
|
1263
|
+
- `-2`: field does not exist or key does not exist
|
|
1264
|
+
|
|
1265
|
+
Examples:
|
|
1266
|
+
>>> import time
|
|
1267
|
+
>>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
|
|
1268
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_MILLSEC, future_timestamp_ms))
|
|
1269
|
+
>>> await client.hpexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
|
|
1270
|
+
[future_timestamp_ms, future_timestamp_ms, -2] # field1 and field2 expire at future_timestamp_ms, non_existent_field doesn't exist
|
|
1271
|
+
|
|
1272
|
+
Since: Valkey 9.0.0
|
|
1273
|
+
"""
|
|
1274
|
+
return cast(
|
|
1275
|
+
List[int],
|
|
1276
|
+
await self._execute_command(
|
|
1277
|
+
RequestType.HPExpireTime, [key, "FIELDS", str(len(fields))] + fields
|
|
1278
|
+
),
|
|
1279
|
+
)
|
|
1280
|
+
|
|
1281
|
+
async def hsetex(
|
|
1282
|
+
self,
|
|
1283
|
+
key: TEncodable,
|
|
1284
|
+
field_value_map: Mapping[TEncodable, TEncodable],
|
|
1285
|
+
field_conditional_change: Optional[HashFieldConditionalChange] = None,
|
|
1286
|
+
expiry: Optional[ExpirySet] = None,
|
|
1287
|
+
) -> int:
|
|
1288
|
+
"""
|
|
1289
|
+
Sets the specified fields to their respective values in the hash stored at `key` with optional expiration.
|
|
1290
|
+
|
|
1291
|
+
See [valkey.io](https://valkey.io/commands/hsetex/) for more details.
|
|
1292
|
+
|
|
1293
|
+
Args:
|
|
1294
|
+
key (TEncodable): The key of the hash.
|
|
1295
|
+
field_value_map (Mapping[TEncodable, TEncodable]): A field-value map consisting of fields and their corresponding
|
|
1296
|
+
values to be set in the hash stored at the specified key.
|
|
1297
|
+
field_conditional_change (Optional[HashFieldConditionalChange]): Field conditional change option:
|
|
1298
|
+
- ONLY_IF_ALL_EXIST (FXX): Only set fields if all of them already exist.
|
|
1299
|
+
- ONLY_IF_NONE_EXIST (FNX): Only set fields if none of them already exist.
|
|
1300
|
+
expiry (Optional[ExpirySet]): Expiration options for the fields:
|
|
1301
|
+
- SEC (EX): Expiration time in seconds.
|
|
1302
|
+
- MILLSEC (PX): Expiration time in milliseconds.
|
|
1303
|
+
- UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
|
|
1304
|
+
- UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
|
|
1305
|
+
- KEEP_TTL (KEEPTTL): Retain existing TTL.
|
|
1306
|
+
|
|
1307
|
+
Returns:
|
|
1308
|
+
int: 1 if all fields were set successfully, 0 if none were set due to conditional constraints.
|
|
1309
|
+
|
|
1310
|
+
Examples:
|
|
1311
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
|
|
1312
|
+
1 # All fields set with 10 second expiration
|
|
1313
|
+
>>> await client.hsetex("my_hash", {"field3": "value3"}, field_conditional_change=HashFieldConditionalChange.ONLY_IF_ALL_EXIST)
|
|
1314
|
+
1 # Field set because field already exists
|
|
1315
|
+
>>> await client.hsetex("new_hash", {"field1": "value1"}, field_conditional_change=HashFieldConditionalChange.ONLY_IF_ALL_EXIST)
|
|
1316
|
+
0 # No fields set because hash doesn't exist
|
|
1317
|
+
|
|
1318
|
+
Since: Valkey 9.0.0
|
|
1319
|
+
"""
|
|
1320
|
+
args: List[TEncodable] = [key]
|
|
1321
|
+
|
|
1322
|
+
# Add field conditional change option if specified
|
|
1323
|
+
if field_conditional_change is not None:
|
|
1324
|
+
args.append(field_conditional_change.value)
|
|
1325
|
+
|
|
1326
|
+
# Add expiry options if specified
|
|
1327
|
+
if expiry is not None:
|
|
1328
|
+
args.extend(expiry.get_cmd_args())
|
|
1329
|
+
|
|
1330
|
+
# Add FIELDS keyword and field count
|
|
1331
|
+
args.extend(["FIELDS", str(len(field_value_map))])
|
|
1332
|
+
|
|
1333
|
+
# Add field-value pairs
|
|
1334
|
+
for field, value in field_value_map.items():
|
|
1335
|
+
args.extend([field, value])
|
|
1336
|
+
|
|
1337
|
+
return cast(
|
|
1338
|
+
int,
|
|
1339
|
+
await self._execute_command(RequestType.HSetEx, args),
|
|
1340
|
+
)
|
|
1341
|
+
|
|
1342
|
+
async def hgetex(
|
|
1343
|
+
self,
|
|
1344
|
+
key: TEncodable,
|
|
1345
|
+
fields: List[TEncodable],
|
|
1346
|
+
expiry: Optional[ExpiryGetEx] = None,
|
|
1347
|
+
) -> Optional[List[Optional[bytes]]]:
|
|
1348
|
+
"""
|
|
1349
|
+
Retrieves the values of specified fields in the hash stored at `key` and optionally sets their expiration.
|
|
1350
|
+
|
|
1351
|
+
See [valkey.io](https://valkey.io/commands/hgetex/) for more details.
|
|
1352
|
+
|
|
1353
|
+
Args:
|
|
1354
|
+
key (TEncodable): The key of the hash.
|
|
1355
|
+
fields (List[TEncodable]): The list of fields to retrieve from the hash.
|
|
1356
|
+
expiry (Optional[ExpiryGetEx]): Expiration options for the retrieved fields:
|
|
1357
|
+
- SEC (EX): Expiration time in seconds.
|
|
1358
|
+
- MILLSEC (PX): Expiration time in milliseconds.
|
|
1359
|
+
- UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
|
|
1360
|
+
- UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
|
|
1361
|
+
- PERSIST: Remove expiration from the fields.
|
|
1362
|
+
|
|
1363
|
+
Returns:
|
|
1364
|
+
Optional[List[Optional[bytes]]]: A list of values associated with the given fields, in the same order as requested.
|
|
1365
|
+
For every field that does not exist in the hash, a null value is returned.
|
|
1366
|
+
If `key` does not exist, it is treated as an empty hash, and the function returns a list of null values.
|
|
1367
|
+
|
|
1368
|
+
Examples:
|
|
1369
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
|
|
1370
|
+
>>> await client.hgetex("my_hash", ["field1", "field2"])
|
|
1371
|
+
[b"value1", b"value2"]
|
|
1372
|
+
>>> await client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.SEC, 20))
|
|
1373
|
+
[b"value1"] # field1 now has 20 second expiration
|
|
1374
|
+
>>> await client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.PERSIST, None))
|
|
1375
|
+
[b"value1"] # field1 expiration removed
|
|
1376
|
+
|
|
1377
|
+
Since: Valkey 9.0.0
|
|
1378
|
+
"""
|
|
1379
|
+
args: List[TEncodable] = [key]
|
|
1380
|
+
|
|
1381
|
+
# Add expiry options if specified
|
|
1382
|
+
if expiry is not None:
|
|
1383
|
+
args.extend(expiry.get_cmd_args())
|
|
1384
|
+
|
|
1385
|
+
# Add FIELDS keyword and field count
|
|
1386
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1387
|
+
|
|
1388
|
+
# Add fields
|
|
1389
|
+
args.extend(fields)
|
|
1390
|
+
|
|
1391
|
+
return cast(
|
|
1392
|
+
Optional[List[Optional[bytes]]],
|
|
1393
|
+
await self._execute_command(RequestType.HGetEx, args),
|
|
1394
|
+
)
|
|
1395
|
+
|
|
1396
|
+
async def hexpire(
|
|
1397
|
+
self,
|
|
1398
|
+
key: TEncodable,
|
|
1399
|
+
seconds: int,
|
|
1400
|
+
fields: List[TEncodable],
|
|
1401
|
+
option: Optional[ExpireOptions] = None,
|
|
1402
|
+
) -> List[int]:
|
|
1403
|
+
"""
|
|
1404
|
+
Sets expiration time in seconds for one or more hash fields.
|
|
1405
|
+
|
|
1406
|
+
See [valkey.io](https://valkey.io/commands/hexpire/) for more details.
|
|
1407
|
+
|
|
1408
|
+
Args:
|
|
1409
|
+
key (TEncodable): The key of the hash.
|
|
1410
|
+
seconds (int): The expiration time in seconds.
|
|
1411
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1412
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1413
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1414
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1415
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1416
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1417
|
+
|
|
1418
|
+
Returns:
|
|
1419
|
+
List[int]: A list of status codes for each field:
|
|
1420
|
+
- `1`: Expiration time was applied successfully.
|
|
1421
|
+
- `0`: Specified condition was not met.
|
|
1422
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1423
|
+
- `2`: Field was deleted immediately (when seconds is 0 or timestamp is in the past).
|
|
1424
|
+
|
|
1425
|
+
Examples:
|
|
1426
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
|
|
1427
|
+
>>> await client.hexpire("my_hash", 20, ["field1", "field2"])
|
|
1428
|
+
[1, 1] # Both fields' expiration set to 20 seconds
|
|
1429
|
+
>>> await client.hexpire("my_hash", 30, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
|
|
1430
|
+
[1] # field1 expiration updated to 30 seconds (greater than current 20)
|
|
1431
|
+
>>> await client.hexpire("my_hash", 0, ["field2"])
|
|
1432
|
+
[2] # field2 deleted immediately
|
|
1433
|
+
>>> await client.hexpire("my_hash", 10, ["non_existent_field"])
|
|
1434
|
+
[-2] # Field doesn't exist
|
|
1435
|
+
|
|
1436
|
+
Since: Valkey 9.0.0
|
|
1437
|
+
"""
|
|
1438
|
+
args: List[TEncodable] = [key, str(seconds)]
|
|
1439
|
+
|
|
1440
|
+
# Add conditional option if specified
|
|
1441
|
+
if option is not None:
|
|
1442
|
+
args.append(option.value)
|
|
1443
|
+
|
|
1444
|
+
# Add FIELDS keyword and field count
|
|
1445
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1446
|
+
|
|
1447
|
+
# Add fields
|
|
1448
|
+
args.extend(fields)
|
|
1449
|
+
|
|
1450
|
+
return cast(
|
|
1451
|
+
List[int],
|
|
1452
|
+
await self._execute_command(RequestType.HExpire, args),
|
|
1453
|
+
)
|
|
1454
|
+
|
|
1455
|
+
async def hpersist(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
|
|
1456
|
+
"""
|
|
1457
|
+
Removes the expiration from one or more hash fields, making them persistent.
|
|
1458
|
+
|
|
1459
|
+
See [valkey.io](https://valkey.io/commands/hpersist/) for more details.
|
|
1460
|
+
|
|
1461
|
+
Args:
|
|
1462
|
+
key (TEncodable): The key of the hash.
|
|
1463
|
+
fields (List[TEncodable]): The list of fields to remove expiration from.
|
|
1464
|
+
|
|
1465
|
+
Returns:
|
|
1466
|
+
List[int]: A list of status codes for each field:
|
|
1467
|
+
- `1`: Expiration was removed successfully (field became persistent).
|
|
1468
|
+
- `-1`: Field exists but has no expiration.
|
|
1469
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1470
|
+
|
|
1471
|
+
Examples:
|
|
1472
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
|
|
1473
|
+
>>> await client.hpersist("my_hash", ["field1", "field2"])
|
|
1474
|
+
[1, 1] # Both fields made persistent
|
|
1475
|
+
>>> await client.hpersist("my_hash", ["field1"])
|
|
1476
|
+
[-1] # field1 already persistent
|
|
1477
|
+
>>> await client.hpersist("my_hash", ["non_existent_field"])
|
|
1478
|
+
[-2] # Field doesn't exist
|
|
1479
|
+
|
|
1480
|
+
Since: Valkey 9.0.0
|
|
1481
|
+
"""
|
|
1482
|
+
args: List[TEncodable] = [key, "FIELDS", str(len(fields))] + fields
|
|
1483
|
+
|
|
1484
|
+
return cast(
|
|
1485
|
+
List[int],
|
|
1486
|
+
await self._execute_command(RequestType.HPersist, args),
|
|
1487
|
+
)
|
|
1488
|
+
|
|
1489
|
+
async def hpexpire(
|
|
1490
|
+
self,
|
|
1491
|
+
key: TEncodable,
|
|
1492
|
+
milliseconds: int,
|
|
1493
|
+
fields: List[TEncodable],
|
|
1494
|
+
option: Optional[ExpireOptions] = None,
|
|
1495
|
+
) -> List[int]:
|
|
1496
|
+
"""
|
|
1497
|
+
Sets expiration time in milliseconds for one or more hash fields.
|
|
1498
|
+
|
|
1499
|
+
See [valkey.io](https://valkey.io/commands/hpexpire/) for more details.
|
|
1500
|
+
|
|
1501
|
+
Args:
|
|
1502
|
+
key (TEncodable): The key of the hash.
|
|
1503
|
+
milliseconds (int): The expiration time in milliseconds.
|
|
1504
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1505
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1506
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1507
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1508
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1509
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1510
|
+
|
|
1511
|
+
Returns:
|
|
1512
|
+
List[int]: A list of status codes for each field:
|
|
1513
|
+
- `1`: Expiration time was applied successfully.
|
|
1514
|
+
- `0`: Specified condition was not met.
|
|
1515
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1516
|
+
- `2`: Field was deleted immediately (when milliseconds is 0 or timestamp is in the past).
|
|
1517
|
+
|
|
1518
|
+
Examples:
|
|
1519
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
|
|
1520
|
+
>>> await client.hpexpire("my_hash", 20000, ["field1", "field2"])
|
|
1521
|
+
[1, 1] # Both fields' expiration set to 20000 milliseconds
|
|
1522
|
+
>>> await client.hpexpire("my_hash", 30000, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
|
|
1523
|
+
[1] # field1 expiration updated to 30000 milliseconds (greater than current 20000)
|
|
1524
|
+
>>> await client.hpexpire("my_hash", 0, ["field2"])
|
|
1525
|
+
[2] # field2 deleted immediately
|
|
1526
|
+
>>> await client.hpexpire("my_hash", 10000, ["non_existent_field"])
|
|
1527
|
+
[-2] # Field doesn't exist
|
|
1528
|
+
|
|
1529
|
+
Since: Valkey 9.0.0
|
|
1530
|
+
"""
|
|
1531
|
+
args: List[TEncodable] = [key, str(milliseconds)]
|
|
1532
|
+
|
|
1533
|
+
# Add conditional option if specified
|
|
1534
|
+
if option is not None:
|
|
1535
|
+
args.append(option.value)
|
|
1536
|
+
|
|
1537
|
+
# Add FIELDS keyword and field count
|
|
1538
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1539
|
+
|
|
1540
|
+
# Add fields
|
|
1541
|
+
args.extend(fields)
|
|
1542
|
+
|
|
1543
|
+
return cast(
|
|
1544
|
+
List[int],
|
|
1545
|
+
await self._execute_command(RequestType.HPExpire, args),
|
|
1546
|
+
)
|
|
1547
|
+
|
|
1548
|
+
async def hexpireat(
|
|
1549
|
+
self,
|
|
1550
|
+
key: TEncodable,
|
|
1551
|
+
unix_timestamp: int,
|
|
1552
|
+
fields: List[TEncodable],
|
|
1553
|
+
option: Optional[ExpireOptions] = None,
|
|
1554
|
+
) -> List[int]:
|
|
1555
|
+
"""
|
|
1556
|
+
Sets expiration time at absolute Unix timestamp in seconds for one or more hash fields.
|
|
1557
|
+
|
|
1558
|
+
See [valkey.io](https://valkey.io/commands/hexpireat/) for more details.
|
|
1559
|
+
|
|
1560
|
+
Args:
|
|
1561
|
+
key (TEncodable): The key of the hash.
|
|
1562
|
+
unix_timestamp (int): The absolute expiration time as Unix timestamp in seconds.
|
|
1563
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1564
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1565
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1566
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1567
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1568
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1569
|
+
|
|
1570
|
+
Returns:
|
|
1571
|
+
List[int]: A list of status codes for each field:
|
|
1572
|
+
- `1`: Expiration time was applied successfully.
|
|
1573
|
+
- `0`: Specified condition was not met.
|
|
1574
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1575
|
+
- `2`: Field was deleted immediately (when timestamp is in the past).
|
|
1576
|
+
|
|
1577
|
+
Examples:
|
|
1578
|
+
>>> import time
|
|
1579
|
+
>>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
|
|
1580
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
|
|
1581
|
+
>>> await client.hexpireat("my_hash", future_timestamp, ["field1", "field2"])
|
|
1582
|
+
[1, 1] # Both fields' expiration set to future_timestamp
|
|
1583
|
+
>>> past_timestamp = int(time.time()) - 60 # 60 seconds ago
|
|
1584
|
+
>>> await client.hexpireat("my_hash", past_timestamp, ["field1"])
|
|
1585
|
+
[2] # field1 deleted immediately (past timestamp)
|
|
1586
|
+
>>> await client.hexpireat("my_hash", future_timestamp, ["non_existent_field"])
|
|
1587
|
+
[-2] # Field doesn't exist
|
|
1588
|
+
|
|
1589
|
+
Since: Valkey 9.0.0
|
|
1590
|
+
"""
|
|
1591
|
+
args: List[TEncodable] = [key, str(unix_timestamp)]
|
|
1592
|
+
|
|
1593
|
+
# Add conditional option if specified
|
|
1594
|
+
if option is not None:
|
|
1595
|
+
args.append(option.value)
|
|
1596
|
+
|
|
1597
|
+
# Add FIELDS keyword and field count
|
|
1598
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1599
|
+
|
|
1600
|
+
# Add fields
|
|
1601
|
+
args.extend(fields)
|
|
1602
|
+
|
|
1603
|
+
return cast(
|
|
1604
|
+
List[int],
|
|
1605
|
+
await self._execute_command(RequestType.HExpireAt, args),
|
|
1606
|
+
)
|
|
1607
|
+
|
|
1608
|
+
async def hpexpireat(
|
|
1609
|
+
self,
|
|
1610
|
+
key: TEncodable,
|
|
1611
|
+
unix_timestamp_ms: int,
|
|
1612
|
+
fields: List[TEncodable],
|
|
1613
|
+
option: Optional[ExpireOptions] = None,
|
|
1614
|
+
) -> List[int]:
|
|
1615
|
+
"""
|
|
1616
|
+
Sets expiration time at absolute Unix timestamp in milliseconds for one or more hash fields.
|
|
1617
|
+
|
|
1618
|
+
See [valkey.io](https://valkey.io/commands/hpexpireat/) for more details.
|
|
1619
|
+
|
|
1620
|
+
Args:
|
|
1621
|
+
key (TEncodable): The key of the hash.
|
|
1622
|
+
unix_timestamp_ms (int): The absolute expiration time as Unix timestamp in milliseconds.
|
|
1623
|
+
fields (List[TEncodable]): The list of fields to set expiration for.
|
|
1624
|
+
option (Optional[ExpireOptions]): Conditional expiration option:
|
|
1625
|
+
- HasNoExpiry (NX): Set expiration only when the field has no expiry.
|
|
1626
|
+
- HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
|
|
1627
|
+
- NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
|
|
1628
|
+
- NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
|
|
1629
|
+
|
|
1630
|
+
Returns:
|
|
1631
|
+
List[int]: A list of status codes for each field:
|
|
1632
|
+
- `1`: Expiration time was applied successfully.
|
|
1633
|
+
- `0`: Specified condition was not met.
|
|
1634
|
+
- `-2`: Field does not exist or key does not exist.
|
|
1635
|
+
- `2`: Field was deleted immediately (when timestamp is in the past).
|
|
1636
|
+
|
|
1637
|
+
Examples:
|
|
1638
|
+
>>> import time
|
|
1639
|
+
>>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
|
|
1640
|
+
>>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
|
|
1641
|
+
>>> await client.hpexpireat("my_hash", future_timestamp_ms, ["field1", "field2"])
|
|
1642
|
+
[1, 1] # Both fields' expiration set to future_timestamp_ms
|
|
1643
|
+
>>> past_timestamp_ms = int(time.time() * 1000) - 60000 # 60 seconds ago in milliseconds
|
|
1644
|
+
>>> await client.hpexpireat("my_hash", past_timestamp_ms, ["field1"])
|
|
1645
|
+
[2] # field1 deleted immediately (past timestamp)
|
|
1646
|
+
>>> await client.hpexpireat("my_hash", future_timestamp_ms, ["non_existent_field"])
|
|
1647
|
+
[-2] # Field doesn't exist
|
|
1648
|
+
|
|
1649
|
+
Since: Valkey 9.0.0
|
|
1650
|
+
"""
|
|
1651
|
+
args: List[TEncodable] = [key, str(unix_timestamp_ms)]
|
|
1652
|
+
|
|
1653
|
+
# Add conditional option if specified
|
|
1654
|
+
if option is not None:
|
|
1655
|
+
args.append(option.value)
|
|
1656
|
+
|
|
1657
|
+
# Add FIELDS keyword and field count
|
|
1658
|
+
args.extend(["FIELDS", str(len(fields))])
|
|
1659
|
+
|
|
1660
|
+
# Add fields
|
|
1661
|
+
args.extend(fields)
|
|
1662
|
+
|
|
1663
|
+
return cast(
|
|
1664
|
+
List[int],
|
|
1665
|
+
await self._execute_command(RequestType.HPExpireAt, args),
|
|
1666
|
+
)
|
|
1667
|
+
|
|
1480
1668
|
async def lpush(self, key: TEncodable, elements: List[TEncodable]) -> int:
|
|
1481
1669
|
"""
|
|
1482
1670
|
Insert all the specified values at the head of the list stored at `key`.
|
|
@@ -2103,6 +2291,20 @@ class CoreCommands(Protocol):
|
|
|
2103
2291
|
"""
|
|
2104
2292
|
return cast(int, await self._execute_command(RequestType.SAdd, [key] + members))
|
|
2105
2293
|
|
|
2294
|
+
async def select(self, index: int) -> TOK:
|
|
2295
|
+
"""
|
|
2296
|
+
Change the currently selected database.
|
|
2297
|
+
|
|
2298
|
+
See [valkey.io](https://valkey.io/commands/select/) for details.
|
|
2299
|
+
|
|
2300
|
+
Args:
|
|
2301
|
+
index (int): The index of the database to select.
|
|
2302
|
+
|
|
2303
|
+
Returns:
|
|
2304
|
+
A simple OK response.
|
|
2305
|
+
"""
|
|
2306
|
+
return cast(TOK, await self._execute_command(RequestType.Select, [str(index)]))
|
|
2307
|
+
|
|
2106
2308
|
async def srem(self, key: TEncodable, members: List[TEncodable]) -> int:
|
|
2107
2309
|
"""
|
|
2108
2310
|
Remove specified members from the set stored at `key`.
|
|
@@ -2535,8 +2737,8 @@ class CoreCommands(Protocol):
|
|
|
2535
2737
|
Returns:
|
|
2536
2738
|
TOK: A simple "OK" response.
|
|
2537
2739
|
|
|
2538
|
-
If `start` exceeds the end of the list, or if `start` is greater than `end`, the
|
|
2539
|
-
|
|
2740
|
+
If `start` exceeds the end of the list, or if `start` is greater than `end`, the list is emptied
|
|
2741
|
+
and the key is removed.
|
|
2540
2742
|
|
|
2541
2743
|
If `end` exceeds the actual end of the list, it will be treated like the last element of the list.
|
|
2542
2744
|
|
|
@@ -2554,9 +2756,6 @@ class CoreCommands(Protocol):
|
|
|
2554
2756
|
async def lrem(self, key: TEncodable, count: int, element: TEncodable) -> int:
|
|
2555
2757
|
"""
|
|
2556
2758
|
Removes the first `count` occurrences of elements equal to `element` from the list stored at `key`.
|
|
2557
|
-
If `count` is positive, it removes elements equal to `element` moving from head to tail.
|
|
2558
|
-
If `count` is negative, it removes elements equal to `element` moving from tail to head.
|
|
2559
|
-
If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
|
|
2560
2759
|
equal to `element`.
|
|
2561
2760
|
|
|
2562
2761
|
See [valkey.io](https://valkey.io/commands/lrem/) for more details.
|
|
@@ -2564,6 +2763,11 @@ class CoreCommands(Protocol):
|
|
|
2564
2763
|
Args:
|
|
2565
2764
|
key (TEncodable): The key of the list.
|
|
2566
2765
|
count (int): The count of occurrences of elements equal to `element` to remove.
|
|
2766
|
+
|
|
2767
|
+
- If `count` is positive, it removes elements equal to `element` moving from head to tail.
|
|
2768
|
+
- If `count` is negative, it removes elements equal to `element` moving from tail to head.
|
|
2769
|
+
- If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
|
|
2770
|
+
|
|
2567
2771
|
element (TEncodable): The element to remove from the list.
|
|
2568
2772
|
|
|
2569
2773
|
Returns:
|
|
@@ -3114,26 +3318,26 @@ class CoreCommands(Protocol):
|
|
|
3114
3318
|
|
|
3115
3319
|
Args:
|
|
3116
3320
|
key (TEncodable): The key of the stream.
|
|
3117
|
-
start (StreamRangeBound): The starting stream ID bound for the range.
|
|
3321
|
+
start (StreamRangeBound): The starting stream entry ID bound for the range.
|
|
3118
3322
|
|
|
3119
|
-
- Use `IdBound` to specify a stream ID.
|
|
3120
|
-
-
|
|
3323
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3324
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
3121
3325
|
- Use `MinId` to start with the minimum available ID.
|
|
3122
3326
|
|
|
3123
|
-
end (StreamRangeBound): The ending stream ID bound for the range.
|
|
3327
|
+
end (StreamRangeBound): The ending stream entry ID bound for the range.
|
|
3124
3328
|
|
|
3125
|
-
- Use `IdBound` to specify a stream ID.
|
|
3126
|
-
-
|
|
3329
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3330
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
3127
3331
|
- Use `MaxId` to end with the maximum available ID.
|
|
3128
3332
|
|
|
3129
3333
|
count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
|
|
3130
3334
|
If `count` is not provided, all stream entries in the range will be returned.
|
|
3131
3335
|
|
|
3132
3336
|
Returns:
|
|
3133
|
-
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
|
|
3337
|
+
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream entry IDs to stream entry data, where entry data is a
|
|
3134
3338
|
list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3135
3339
|
|
|
3136
|
-
Returns None if the range arguments are not applicable.
|
|
3340
|
+
Returns None if the range arguments are not applicable. Or if count is non-positive.
|
|
3137
3341
|
|
|
3138
3342
|
Examples:
|
|
3139
3343
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="0-1"))
|
|
@@ -3168,26 +3372,26 @@ class CoreCommands(Protocol):
|
|
|
3168
3372
|
|
|
3169
3373
|
Args:
|
|
3170
3374
|
key (TEncodable): The key of the stream.
|
|
3171
|
-
end (StreamRangeBound): The ending stream ID bound for the range.
|
|
3375
|
+
end (StreamRangeBound): The ending stream entry ID bound for the range.
|
|
3172
3376
|
|
|
3173
|
-
- Use `IdBound` to specify a stream ID.
|
|
3174
|
-
-
|
|
3377
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3378
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
3175
3379
|
- Use `MaxId` to end with the maximum available ID.
|
|
3176
3380
|
|
|
3177
|
-
start (StreamRangeBound): The starting stream ID bound for the range.
|
|
3381
|
+
start (StreamRangeBound): The starting stream entry ID bound for the range.
|
|
3178
3382
|
|
|
3179
|
-
- Use `IdBound` to specify a stream ID.
|
|
3180
|
-
-
|
|
3383
|
+
- Use `IdBound` to specify a stream entry ID.
|
|
3384
|
+
- Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
|
|
3181
3385
|
- Use `MinId` to start with the minimum available ID.
|
|
3182
3386
|
|
|
3183
3387
|
count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
|
|
3184
3388
|
If `count` is not provided, all stream entries in the range will be returned.
|
|
3185
3389
|
|
|
3186
3390
|
Returns:
|
|
3187
|
-
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
|
|
3391
|
+
Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream entry IDs to stream entry data, where entry data is a
|
|
3188
3392
|
list of pairings with format `[[field, entry], [field, entry], ...]`.
|
|
3189
3393
|
|
|
3190
|
-
Returns None if the range arguments are not applicable.
|
|
3394
|
+
Returns None if the range arguments are not applicable. Or if count is non-positive.
|
|
3191
3395
|
|
|
3192
3396
|
Examples:
|
|
3193
3397
|
>>> await client.xadd("mystream", [("field1", "value1")], StreamAddOptions(id="0-1"))
|
|
@@ -3273,7 +3477,7 @@ class CoreCommands(Protocol):
|
|
|
3273
3477
|
key (TEncodable): The key of the stream.
|
|
3274
3478
|
group_name (TEncodable): The newly created consumer group name.
|
|
3275
3479
|
group_id (TEncodable): The stream entry ID that specifies the last delivered entry in the stream from the new
|
|
3276
|
-
group
|
|
3480
|
+
group's perspective. The special ID "$" can be used to specify the last entry in the stream.
|
|
3277
3481
|
options (Optional[StreamGroupOptions]): Options for creating the stream group.
|
|
3278
3482
|
|
|
3279
3483
|
Returns:
|
|
@@ -3733,7 +3937,7 @@ class CoreCommands(Protocol):
|
|
|
3733
3937
|
min_idle_time_ms (int): Filters the claimed entries to those that have been idle for more than the specified
|
|
3734
3938
|
value.
|
|
3735
3939
|
start (TEncodable): Filters the claimed entries to those that have an ID equal or greater than the specified value.
|
|
3736
|
-
count (Optional[int]): Limits the number of claimed entries to the specified value.
|
|
3940
|
+
count (Optional[int]): Limits the number of claimed entries to the specified value. Default value is 100.
|
|
3737
3941
|
|
|
3738
3942
|
Returns:
|
|
3739
3943
|
List[Union[bytes, Mapping[bytes, List[List[bytes]]], List[bytes]]]: A list containing the following elements:
|
|
@@ -3820,7 +4024,7 @@ class CoreCommands(Protocol):
|
|
|
3820
4024
|
min_idle_time_ms (int): Filters the claimed entries to those that have been idle for more than the specified
|
|
3821
4025
|
value.
|
|
3822
4026
|
start (TEncodable): Filters the claimed entries to those that have an ID equal or greater than the specified value.
|
|
3823
|
-
count (Optional[int]): Limits the number of claimed entries to the specified value.
|
|
4027
|
+
count (Optional[int]): Limits the number of claimed entries to the specified value. Default value is 100.
|
|
3824
4028
|
|
|
3825
4029
|
Returns:
|
|
3826
4030
|
List[Union[bytes, List[bytes]]]: A list containing the following elements:
|
|
@@ -6048,19 +6252,19 @@ class CoreCommands(Protocol):
|
|
|
6048
6252
|
elements (List[TEncodable]): A list of members to add to the HyperLogLog stored at `key`.
|
|
6049
6253
|
|
|
6050
6254
|
Returns:
|
|
6051
|
-
|
|
6052
|
-
altered, then returns
|
|
6255
|
+
bool: If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
|
|
6256
|
+
altered, then returns `True`.
|
|
6053
6257
|
|
|
6054
|
-
Otherwise, returns
|
|
6258
|
+
Otherwise, returns `False`.
|
|
6055
6259
|
|
|
6056
6260
|
Examples:
|
|
6057
6261
|
>>> await client.pfadd("hll_1", ["a", "b", "c" ])
|
|
6058
|
-
|
|
6262
|
+
True # A data structure was created or modified
|
|
6059
6263
|
>>> await client.pfadd("hll_2", [])
|
|
6060
|
-
|
|
6264
|
+
True # A new empty data structure was created
|
|
6061
6265
|
"""
|
|
6062
6266
|
return cast(
|
|
6063
|
-
|
|
6267
|
+
bool,
|
|
6064
6268
|
await self._execute_command(RequestType.PfAdd, [key] + elements),
|
|
6065
6269
|
)
|
|
6066
6270
|
|
|
@@ -6649,6 +6853,10 @@ class CoreCommands(Protocol):
|
|
|
6649
6853
|
args.append("REPLACE")
|
|
6650
6854
|
if absttl is True:
|
|
6651
6855
|
args.append("ABSTTL")
|
|
6856
|
+
if idletime is not None and frequency is not None:
|
|
6857
|
+
raise RequestError(
|
|
6858
|
+
"syntax error: IDLETIME and FREQ cannot be set at the same time."
|
|
6859
|
+
)
|
|
6652
6860
|
if idletime is not None:
|
|
6653
6861
|
args.extend(["IDLETIME", str(idletime)])
|
|
6654
6862
|
if frequency is not None:
|
|
@@ -6987,7 +7195,7 @@ class CoreCommands(Protocol):
|
|
|
6987
7195
|
See [valkey.io](https://valkey.io/commands/watch) for more details.
|
|
6988
7196
|
|
|
6989
7197
|
Note:
|
|
6990
|
-
In cluster mode, if keys in `
|
|
7198
|
+
In cluster mode, if keys in `keys` map to different hash slots,
|
|
6991
7199
|
the command will be split across these slots and executed separately for each.
|
|
6992
7200
|
This means the command is atomic only at the slot level. If one or more slot-specific
|
|
6993
7201
|
requests fail, the entire call will return the first encountered error, even
|
|
@@ -7006,7 +7214,7 @@ class CoreCommands(Protocol):
|
|
|
7006
7214
|
'OK'
|
|
7007
7215
|
>>> transaction.set("sampleKey", "foobar")
|
|
7008
7216
|
>>> await client.exec(transaction)
|
|
7009
|
-
'OK' # Executes successfully and keys are unwatched.
|
|
7217
|
+
['OK'] # Executes successfully and keys are unwatched.
|
|
7010
7218
|
|
|
7011
7219
|
>>> await client.watch("sampleKey")
|
|
7012
7220
|
'OK'
|
|
@@ -7022,21 +7230,6 @@ class CoreCommands(Protocol):
|
|
|
7022
7230
|
await self._execute_command(RequestType.Watch, keys),
|
|
7023
7231
|
)
|
|
7024
7232
|
|
|
7025
|
-
@dataclass
|
|
7026
|
-
class PubSubMsg:
|
|
7027
|
-
"""
|
|
7028
|
-
Describes the incoming pubsub message
|
|
7029
|
-
|
|
7030
|
-
Attributes:
|
|
7031
|
-
message (TEncodable): Incoming message.
|
|
7032
|
-
channel (TEncodable): Name of an channel that triggered the message.
|
|
7033
|
-
pattern (Optional[TEncodable]): Pattern that triggered the message.
|
|
7034
|
-
"""
|
|
7035
|
-
|
|
7036
|
-
message: TEncodable
|
|
7037
|
-
channel: TEncodable
|
|
7038
|
-
pattern: Optional[TEncodable]
|
|
7039
|
-
|
|
7040
7233
|
async def get_pubsub_message(self) -> PubSubMsg:
|
|
7041
7234
|
"""
|
|
7042
7235
|
Returns the next pubsub message.
|