valkey-glide 1.3.5rc4__cp313-cp313-macosx_11_0_arm64.whl → 2.0.0__cp313-cp313-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of valkey-glide might be problematic. Click here for more details.
- glide/__init__.py +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-313-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.5rc4.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.5rc4.dist-info/RECORD +0 -37
- {valkey_glide-1.3.5rc4.dist-info → valkey_glide-2.0.0.dist-info}/WHEEL +0 -0
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Dict, List, Mapping, Optional, Union, cast
|
|
6
6
|
|
|
7
|
-
from glide.async_commands.
|
|
7
|
+
from glide.async_commands.batch import ClusterBatch
|
|
8
|
+
from glide.async_commands.batch_options import ClusterBatchOptions
|
|
9
|
+
from glide.async_commands.command_args import ObjectType
|
|
8
10
|
from glide.async_commands.core import (
|
|
9
11
|
CoreCommands,
|
|
10
12
|
FlushMode,
|
|
11
13
|
FunctionRestorePolicy,
|
|
12
14
|
InfoSection,
|
|
13
|
-
_build_sort_args,
|
|
14
15
|
)
|
|
15
|
-
from glide.async_commands.transaction import ClusterTransaction
|
|
16
16
|
from glide.constants import (
|
|
17
17
|
TOK,
|
|
18
18
|
TClusterResponse,
|
|
@@ -20,8 +20,8 @@ from glide.constants import (
|
|
|
20
20
|
TFunctionListResponse,
|
|
21
21
|
TFunctionStatsSingleNodeResponse,
|
|
22
22
|
TResult,
|
|
23
|
-
TSingleNodeRoute,
|
|
24
23
|
)
|
|
24
|
+
from glide.exceptions import RequestError
|
|
25
25
|
from glide.protobuf.command_request_pb2 import RequestType
|
|
26
26
|
from glide.routes import Route
|
|
27
27
|
|
|
@@ -37,13 +37,19 @@ class ClusterCommands(CoreCommands):
|
|
|
37
37
|
See the [Valkey GLIDE Wiki](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command)
|
|
38
38
|
for details on the restrictions and limitations of the custom command API.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
This function should only be used for single-response commands. Commands that don't return complete response and awaits
|
|
41
|
+
(such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the
|
|
42
|
+
client's behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
|
|
43
|
+
|
|
44
|
+
For example - Return a list of all pub/sub clients from all nodes::
|
|
45
|
+
|
|
46
|
+
await client.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"], AllNodes())
|
|
41
47
|
|
|
42
|
-
connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"], AllNodes())
|
|
43
48
|
Args:
|
|
44
49
|
command_args (List[TEncodable]): List of the command's arguments, where each argument is either a string or bytes.
|
|
45
50
|
Every part of the command, including the command name and subcommands, should be added as a separate value in args.
|
|
46
|
-
route (Optional[Route]): The command will be routed automatically based on the passed command's default request
|
|
51
|
+
route (Optional[Route]): The command will be routed automatically based on the passed command's default request
|
|
52
|
+
policy, unless `route` is provided, in which
|
|
47
53
|
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
48
54
|
|
|
49
55
|
Returns:
|
|
@@ -61,13 +67,16 @@ class ClusterCommands(CoreCommands):
|
|
|
61
67
|
) -> TClusterResponse[bytes]:
|
|
62
68
|
"""
|
|
63
69
|
Get information and statistics about the server.
|
|
64
|
-
|
|
70
|
+
|
|
71
|
+
Starting from server version 7, command supports multiple section arguments.
|
|
72
|
+
|
|
73
|
+
See [valkey.io](https://valkey.io/commands/info/) for details.
|
|
65
74
|
|
|
66
75
|
Args:
|
|
67
76
|
sections (Optional[List[InfoSection]]): A list of InfoSection values specifying which sections of
|
|
68
|
-
|
|
69
|
-
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided, in
|
|
70
|
-
|
|
77
|
+
information to retrieve. When no parameter is provided, the default option is assumed.
|
|
78
|
+
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided, in
|
|
79
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
71
80
|
|
|
72
81
|
Returns:
|
|
73
82
|
TClusterResponse[bytes]: If a single node route is requested, returns a bytes string containing the information for
|
|
@@ -84,27 +93,120 @@ class ClusterCommands(CoreCommands):
|
|
|
84
93
|
|
|
85
94
|
async def exec(
|
|
86
95
|
self,
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
batch: ClusterBatch,
|
|
97
|
+
raise_on_error: bool,
|
|
98
|
+
options: Optional[ClusterBatchOptions] = None,
|
|
89
99
|
) -> Optional[List[TResult]]:
|
|
90
100
|
"""
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
Executes a batch by processing the queued commands.
|
|
102
|
+
|
|
103
|
+
**Routing Behavior:**
|
|
104
|
+
|
|
105
|
+
- If a `route` is specified in `ClusterBatchOptions`, the entire batch is sent
|
|
106
|
+
to the specified node.
|
|
107
|
+
- If no `route` is specified:
|
|
108
|
+
- **Atomic batches (Transactions):** Routed to the slot owner of the
|
|
109
|
+
first key in the batch. If no key is found, the request is sent to a random node.
|
|
110
|
+
- **Non-atomic batches (Pipelines):** Each command is routed to the node
|
|
111
|
+
owning the corresponding key's slot. If no key is present, routing follows the
|
|
112
|
+
command's request policy. Multi-node commands are automatically split and
|
|
113
|
+
dispatched to the appropriate nodes.
|
|
114
|
+
|
|
115
|
+
**Behavior notes:**
|
|
116
|
+
|
|
117
|
+
- **Atomic Batches (Transactions):** All key-based commands must map to the
|
|
118
|
+
same hash slot. If keys span different slots, the transaction will fail. If the
|
|
119
|
+
transaction fails due to a `WATCH` command, `EXEC` will return `None`.
|
|
120
|
+
|
|
121
|
+
**Retry and Redirection:**
|
|
122
|
+
|
|
123
|
+
- If a redirection error occurs:
|
|
124
|
+
- **Atomic batches (Transactions):** The entire transaction will be
|
|
125
|
+
redirected.
|
|
126
|
+
- **Non-atomic batches:** Only commands that encountered redirection
|
|
127
|
+
errors will be redirected.
|
|
128
|
+
- Retries for failures will be handled according to the configured `BatchRetryStrategy`.
|
|
93
129
|
|
|
94
130
|
Args:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
131
|
+
batch (ClusterBatch): A `ClusterBatch` containing the commands to execute.
|
|
132
|
+
raise_on_error (bool): Determines how errors are handled within the batch response.
|
|
133
|
+
When set to `True`, the first encountered error in the batch will be raised as an
|
|
134
|
+
exception of type `RequestError` after all retries and reconnections have been
|
|
135
|
+
executed.
|
|
136
|
+
When set to `False`, errors will be included as part of the batch response,
|
|
137
|
+
allowing the caller to process both successful and failed commands together. In this case,
|
|
138
|
+
error details will be provided as instances of `RequestError`.
|
|
139
|
+
options (Optional[ClusterBatchOptions]): A `ClusterBatchOptions` object containing execution options.
|
|
99
140
|
|
|
100
141
|
Returns:
|
|
101
|
-
Optional[List[TResult]]:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
142
|
+
Optional[List[TResult]]: An array of results, where each entry
|
|
143
|
+
corresponds to a command's execution result.
|
|
144
|
+
|
|
145
|
+
See Also:
|
|
146
|
+
[Valkey Transactions (Atomic Batches)](https://valkey.io/docs/topics/transactions/)
|
|
147
|
+
[Valkey Pipelines (Non-Atomic Batches)](https://valkey.io/docs/topics/pipelining/)
|
|
148
|
+
|
|
149
|
+
Examples:
|
|
150
|
+
# Atomic batch (transaction): all keys must share the same hash slot
|
|
151
|
+
>>> options = ClusterBatchOptions(timeout=1000) # Set a timeout of 1000 milliseconds
|
|
152
|
+
>>> atomic_batch = ClusterBatch(is_atomic=True)
|
|
153
|
+
>>> atomic_batch.set("key", "1")
|
|
154
|
+
>>> atomic_batch.incr("key")
|
|
155
|
+
>>> atomic_batch.get("key")
|
|
156
|
+
>>> atomic_result = await cluster_client.exec(atomic_batch, False, options)
|
|
157
|
+
>>> print(f"Atomic Batch Result: {atomic_result}")
|
|
158
|
+
# Output: Atomic Batch Result: [OK, 2, 2]
|
|
159
|
+
|
|
160
|
+
# Non-atomic batch (pipeline): keys may span different hash slots
|
|
161
|
+
>>> retry_strategy = BatchRetryStrategy(retry_server_error=True, retry_connection_error=False)
|
|
162
|
+
>>> pipeline_options = ClusterBatchOptions(retry_strategy=retry_strategy)
|
|
163
|
+
>>> non_atomic_batch = ClusterBatch(is_atomic=False)
|
|
164
|
+
>>> non_atomic_batch.set("key1", "value1")
|
|
165
|
+
>>> non_atomic_batch.set("key2", "value2")
|
|
166
|
+
>>> non_atomic_batch.get("key1")
|
|
167
|
+
>>> non_atomic_batch.get("key2")
|
|
168
|
+
>>> non_atomic_result = await cluster_client.exec(non_atomic_batch, False, pipeline_options)
|
|
169
|
+
>>> print(f"Non-Atomic Batch Result: {non_atomic_result}")
|
|
170
|
+
# Output: Non-Atomic Batch Result: [OK, OK, value1, value2]
|
|
171
|
+
"""
|
|
172
|
+
commands = batch.commands[:]
|
|
173
|
+
|
|
174
|
+
if (
|
|
175
|
+
batch.is_atomic
|
|
176
|
+
and options
|
|
177
|
+
and options.retry_strategy
|
|
178
|
+
and (
|
|
179
|
+
options.retry_strategy.retry_server_error
|
|
180
|
+
or options.retry_strategy.retry_connection_error
|
|
181
|
+
)
|
|
182
|
+
):
|
|
183
|
+
raise RequestError(
|
|
184
|
+
"Retry strategies are not supported for atomic batches (transactions). "
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# Extract values to make the _execute_batch call cleaner
|
|
188
|
+
retry_server_error = (
|
|
189
|
+
options.retry_strategy.retry_server_error
|
|
190
|
+
if options and options.retry_strategy
|
|
191
|
+
else False
|
|
192
|
+
)
|
|
193
|
+
retry_connection_error = (
|
|
194
|
+
options.retry_strategy.retry_connection_error
|
|
195
|
+
if options and options.retry_strategy
|
|
196
|
+
else False
|
|
197
|
+
)
|
|
198
|
+
route = options.route if options else None
|
|
199
|
+
timeout = options.timeout if options else None
|
|
200
|
+
|
|
201
|
+
return await self._execute_batch(
|
|
202
|
+
commands,
|
|
203
|
+
batch.is_atomic,
|
|
204
|
+
raise_on_error,
|
|
205
|
+
retry_server_error,
|
|
206
|
+
retry_connection_error,
|
|
207
|
+
route,
|
|
208
|
+
timeout,
|
|
209
|
+
)
|
|
108
210
|
|
|
109
211
|
async def config_resetstat(
|
|
110
212
|
self,
|
|
@@ -112,11 +214,12 @@ class ClusterCommands(CoreCommands):
|
|
|
112
214
|
) -> TOK:
|
|
113
215
|
"""
|
|
114
216
|
Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
|
|
115
|
-
|
|
217
|
+
|
|
218
|
+
See [valkey.io](https://valkey.io/commands/config-resetstat/) for details.
|
|
116
219
|
|
|
117
220
|
Args:
|
|
118
|
-
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
119
|
-
|
|
221
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
222
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
120
223
|
|
|
121
224
|
Returns:
|
|
122
225
|
OK: Returns "OK" to confirm that the statistics were successfully reset.
|
|
@@ -131,11 +234,12 @@ class ClusterCommands(CoreCommands):
|
|
|
131
234
|
) -> TOK:
|
|
132
235
|
"""
|
|
133
236
|
Rewrite the configuration file with the current configuration.
|
|
134
|
-
|
|
237
|
+
|
|
238
|
+
See [valkey.io](https://valkey.io/commands/config-rewrite/) for details.
|
|
135
239
|
|
|
136
240
|
Args:
|
|
137
|
-
route (Optional[TRoute]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
138
|
-
|
|
241
|
+
route (Optional[TRoute]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
242
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
139
243
|
|
|
140
244
|
Returns:
|
|
141
245
|
OK: OK is returned when the configuration was rewritten properly. Otherwise an error is raised.
|
|
@@ -154,15 +258,18 @@ class ClusterCommands(CoreCommands):
|
|
|
154
258
|
) -> TClusterResponse[int]:
|
|
155
259
|
"""
|
|
156
260
|
Returns the current connection id.
|
|
157
|
-
|
|
261
|
+
|
|
262
|
+
See [valkey.io](https://valkey.io/commands/client-id/) for more information.
|
|
158
263
|
|
|
159
264
|
Args:
|
|
160
265
|
route (Optional[Route]): The command will be sent to a random node, unless `route` is provided, in which
|
|
161
|
-
|
|
266
|
+
case the client will route the command to the nodes defined by `route`.
|
|
162
267
|
|
|
163
268
|
Returns:
|
|
164
269
|
TClusterResponse[int]: The id of the client.
|
|
270
|
+
|
|
165
271
|
If a single node route is requested, returns a int representing the client's id.
|
|
272
|
+
|
|
166
273
|
Otherwise, returns a dict of [byte , int] where each key contains the address of
|
|
167
274
|
the queried node and the value contains the client's id.
|
|
168
275
|
"""
|
|
@@ -176,14 +283,14 @@ class ClusterCommands(CoreCommands):
|
|
|
176
283
|
) -> bytes:
|
|
177
284
|
"""
|
|
178
285
|
Ping the server.
|
|
179
|
-
|
|
286
|
+
|
|
287
|
+
See [valkey.io](https://valkey.io/commands/ping/) for more details.
|
|
180
288
|
|
|
181
289
|
Args:
|
|
182
290
|
message (Optional[TEncodable]): An optional message to include in the PING command. If not provided,
|
|
183
|
-
|
|
184
|
-
|
|
291
|
+
the server will respond with b"PONG". If provided, the server will respond with a copy of the message.
|
|
185
292
|
route (Optional[Route]): The command will be sent to all primaries, unless `route` is provided, in which
|
|
186
|
-
|
|
293
|
+
case the client will route the command to the nodes defined by `route`
|
|
187
294
|
|
|
188
295
|
Returns:
|
|
189
296
|
bytes: b'PONG' if `message` is not provided, otherwise return a copy of `message`.
|
|
@@ -205,18 +312,21 @@ class ClusterCommands(CoreCommands):
|
|
|
205
312
|
"""
|
|
206
313
|
Get the values of configuration parameters.
|
|
207
314
|
Starting from server version 7, command supports multiple parameters.
|
|
208
|
-
|
|
315
|
+
|
|
316
|
+
See [valkey.io](https://valkey.io/commands/config-get/) for details.
|
|
209
317
|
|
|
210
318
|
Args:
|
|
211
319
|
parameters (List[TEncodable]): A list of configuration parameter names to retrieve values for.
|
|
212
|
-
|
|
213
320
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
214
|
-
|
|
321
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
215
322
|
|
|
216
323
|
Returns:
|
|
217
324
|
TClusterResponse[Dict[bytes, bytes]]: A dictionary of values corresponding to the
|
|
218
325
|
configuration parameters.
|
|
219
|
-
When specifying a route other than a single node, response will be
|
|
326
|
+
When specifying a route other than a single node, response will be::
|
|
327
|
+
|
|
328
|
+
{Address (bytes) : response (Dict[bytes, bytes]) , ... }
|
|
329
|
+
|
|
220
330
|
with type of Dict[bytes, Dict[bytes, bytes]].
|
|
221
331
|
|
|
222
332
|
Examples:
|
|
@@ -238,14 +348,14 @@ class ClusterCommands(CoreCommands):
|
|
|
238
348
|
"""
|
|
239
349
|
Set configuration parameters to the specified values.
|
|
240
350
|
Starting from server version 7, command supports multiple parameters.
|
|
241
|
-
|
|
351
|
+
|
|
352
|
+
See [valkey.io](https://valkey.io/commands/config-set/) for details.
|
|
242
353
|
|
|
243
354
|
Args:
|
|
244
355
|
parameters_map (Mapping[TEncodable, TEncodable]): A map consisting of configuration
|
|
245
|
-
|
|
246
|
-
|
|
356
|
+
parameters and their respective values to set.
|
|
247
357
|
route (Optional[Route]): The command will be routed to all nodes, unless `route` is provided,
|
|
248
|
-
|
|
358
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
249
359
|
|
|
250
360
|
Returns:
|
|
251
361
|
OK: Returns OK if all configurations have been successfully set. Otherwise, raises an error.
|
|
@@ -267,17 +377,22 @@ class ClusterCommands(CoreCommands):
|
|
|
267
377
|
) -> TClusterResponse[Optional[bytes]]:
|
|
268
378
|
"""
|
|
269
379
|
Get the name of the connection to which the request is routed.
|
|
270
|
-
|
|
380
|
+
|
|
381
|
+
See [valkey.io](https://valkey.io/commands/client-getname/) for more details.
|
|
271
382
|
|
|
272
383
|
Args:
|
|
273
384
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
274
|
-
|
|
385
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
275
386
|
|
|
276
387
|
Returns:
|
|
277
388
|
TClusterResponse[Optional[bytes]]: The name of the client connection as a bytes string if a name is set,
|
|
278
389
|
or None if no name is assigned.
|
|
279
|
-
|
|
280
|
-
|
|
390
|
+
|
|
391
|
+
When specifying a route other than a single node, response will be::
|
|
392
|
+
|
|
393
|
+
{Address (bytes) : response (Optional[bytes]) , ... }
|
|
394
|
+
|
|
395
|
+
with type of Dict[str, Optional[str]].
|
|
281
396
|
|
|
282
397
|
Examples:
|
|
283
398
|
>>> await client.client_getname()
|
|
@@ -293,15 +408,18 @@ class ClusterCommands(CoreCommands):
|
|
|
293
408
|
async def dbsize(self, route: Optional[Route] = None) -> int:
|
|
294
409
|
"""
|
|
295
410
|
Returns the number of keys in the database.
|
|
296
|
-
|
|
411
|
+
|
|
412
|
+
See [valkey.io](https://valkey.io/commands/dbsize) for more details.
|
|
297
413
|
|
|
298
414
|
Args:
|
|
299
415
|
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided,
|
|
300
|
-
|
|
416
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
301
417
|
|
|
302
418
|
Returns:
|
|
303
419
|
int: The number of keys in the database.
|
|
304
|
-
|
|
420
|
+
|
|
421
|
+
In the case of routing the query to multiple nodes, returns the aggregated number of keys across the
|
|
422
|
+
different nodes.
|
|
305
423
|
|
|
306
424
|
Examples:
|
|
307
425
|
>>> await client.dbsize()
|
|
@@ -315,17 +433,21 @@ class ClusterCommands(CoreCommands):
|
|
|
315
433
|
"""
|
|
316
434
|
Echoes the provided `message` back.
|
|
317
435
|
|
|
318
|
-
See https://valkey.io/commands/echo for more details.
|
|
436
|
+
See [valkey.io](https://valkey.io/commands/echo) for more details.
|
|
319
437
|
|
|
320
438
|
Args:
|
|
321
439
|
message (TEncodable): The message to be echoed back.
|
|
322
440
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
323
|
-
|
|
441
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
324
442
|
|
|
325
443
|
Returns:
|
|
326
444
|
TClusterResponse[bytes]: The provided `message`.
|
|
327
|
-
|
|
328
|
-
|
|
445
|
+
|
|
446
|
+
When specifying a route other than a single node, response will be::
|
|
447
|
+
|
|
448
|
+
{Address (bytes) : response (bytes) , ... }
|
|
449
|
+
|
|
450
|
+
with type of Dict[bytes, bytes].
|
|
329
451
|
|
|
330
452
|
Examples:
|
|
331
453
|
>>> await client.echo(b"Valkey GLIDE")
|
|
@@ -347,7 +469,7 @@ class ClusterCommands(CoreCommands):
|
|
|
347
469
|
"""
|
|
348
470
|
Loads a library to Valkey.
|
|
349
471
|
|
|
350
|
-
See https://valkey.io/commands/function-load/ for more details.
|
|
472
|
+
See [valkey.io](https://valkey.io/commands/function-load/) for more details.
|
|
351
473
|
|
|
352
474
|
Args:
|
|
353
475
|
library_code (TEncodable): The source code that implements the library.
|
|
@@ -360,7 +482,7 @@ class ClusterCommands(CoreCommands):
|
|
|
360
482
|
bytes: The library name that was loaded.
|
|
361
483
|
|
|
362
484
|
Examples:
|
|
363
|
-
>>> code = "#!lua name=mylib
|
|
485
|
+
>>> code = "#!lua name=mylib \\n redis.register_function('myfunc', function(keys, args) return args[1] end)"
|
|
364
486
|
>>> await client.function_load(code, True, RandomNode())
|
|
365
487
|
b"mylib"
|
|
366
488
|
|
|
@@ -384,7 +506,7 @@ class ClusterCommands(CoreCommands):
|
|
|
384
506
|
"""
|
|
385
507
|
Returns information about the functions and libraries.
|
|
386
508
|
|
|
387
|
-
See https://valkey.io/commands/function-list/ for more details.
|
|
509
|
+
See [valkey.io](https://valkey.io/commands/function-list/) for more details.
|
|
388
510
|
|
|
389
511
|
Args:
|
|
390
512
|
library_name_pattern (Optional[TEncodable]): A wildcard pattern for matching library names.
|
|
@@ -406,7 +528,9 @@ class ClusterCommands(CoreCommands):
|
|
|
406
528
|
b"description": None,
|
|
407
529
|
b"flags": {b"no-writes"},
|
|
408
530
|
}],
|
|
409
|
-
b"library_code":
|
|
531
|
+
b"library_code":
|
|
532
|
+
b"#!lua name=mylib \\n redis.register_function('myfunc', function(keys, args) " \\
|
|
533
|
+
b"return args[1] end)"
|
|
410
534
|
}]
|
|
411
535
|
|
|
412
536
|
Since: Valkey 7.0.0.
|
|
@@ -431,7 +555,7 @@ class ClusterCommands(CoreCommands):
|
|
|
431
555
|
"""
|
|
432
556
|
Deletes all function libraries.
|
|
433
557
|
|
|
434
|
-
See https://valkey.io/commands/function-flush/ for more details.
|
|
558
|
+
See [valkey.io](https://valkey.io/commands/function-flush/) for more details.
|
|
435
559
|
|
|
436
560
|
Args:
|
|
437
561
|
mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -462,10 +586,10 @@ class ClusterCommands(CoreCommands):
|
|
|
462
586
|
"""
|
|
463
587
|
Deletes a library and all its functions.
|
|
464
588
|
|
|
465
|
-
See https://valkey.io/commands/function-delete/ for more details.
|
|
589
|
+
See [valkey.io](https://valkey.io/commands/function-delete/) for more details.
|
|
466
590
|
|
|
467
591
|
Args:
|
|
468
|
-
|
|
592
|
+
library_name (TEncodable): The library name to delete
|
|
469
593
|
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided,
|
|
470
594
|
in which case the client will route the command to the nodes defined by `route`.
|
|
471
595
|
|
|
@@ -492,7 +616,7 @@ class ClusterCommands(CoreCommands):
|
|
|
492
616
|
Kills a function that is currently executing.
|
|
493
617
|
This command only terminates read-only functions.
|
|
494
618
|
|
|
495
|
-
See https://valkey.io/commands/function-kill/ for more details.
|
|
619
|
+
See [valkey.io](https://valkey.io/commands/function-kill/) for more details.
|
|
496
620
|
|
|
497
621
|
Args:
|
|
498
622
|
route (Optional[Route]): The command will be routed to all nodes, unless `route` is provided,
|
|
@@ -524,7 +648,8 @@ class ClusterCommands(CoreCommands):
|
|
|
524
648
|
) -> TClusterResponse[TResult]:
|
|
525
649
|
"""
|
|
526
650
|
Invokes a previously loaded function.
|
|
527
|
-
|
|
651
|
+
|
|
652
|
+
See [valkey.io](https://valkey.io/commands/fcall/) for more details.
|
|
528
653
|
|
|
529
654
|
Args:
|
|
530
655
|
function (TEncodable): The function name.
|
|
@@ -534,13 +659,18 @@ class ClusterCommands(CoreCommands):
|
|
|
534
659
|
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
535
660
|
|
|
536
661
|
Returns:
|
|
537
|
-
TClusterResponse[TResult]:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
662
|
+
TClusterResponse[TResult]: If a single node route is requested,
|
|
663
|
+
returns a Optional[TResult] representing the function's return value.
|
|
664
|
+
|
|
665
|
+
Otherwise, returns a dict of [bytes , Optional[TResult]] where each key contains the address of
|
|
666
|
+
the queried node and the value contains the function's return value.
|
|
541
667
|
|
|
542
668
|
Example:
|
|
543
|
-
>>> await client.fcall(
|
|
669
|
+
>>> await client.fcall(
|
|
670
|
+
... "Deep_Thought",
|
|
671
|
+
... ["Answer", "to", "the", "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything"],
|
|
672
|
+
... RandomNode()
|
|
673
|
+
... )
|
|
544
674
|
b'new_value' # Returns the function's return value.
|
|
545
675
|
|
|
546
676
|
Since: Valkey version 7.0.0.
|
|
@@ -562,7 +692,7 @@ class ClusterCommands(CoreCommands):
|
|
|
562
692
|
"""
|
|
563
693
|
Invokes a previously loaded read-only function.
|
|
564
694
|
|
|
565
|
-
See https://valkey.io/commands/fcall_ro for more details.
|
|
695
|
+
See [valkey.io](https://valkey.io/commands/fcall_ro) for more details.
|
|
566
696
|
|
|
567
697
|
Args:
|
|
568
698
|
function (TEncodable): The function name.
|
|
@@ -595,17 +725,19 @@ class ClusterCommands(CoreCommands):
|
|
|
595
725
|
Returns information about the function that's currently running and information about the
|
|
596
726
|
available execution engines.
|
|
597
727
|
|
|
598
|
-
See https://valkey.io/commands/function-stats/ for more details
|
|
728
|
+
See [valkey.io](https://valkey.io/commands/function-stats/) for more details
|
|
599
729
|
|
|
600
730
|
Args:
|
|
601
|
-
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
602
|
-
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
731
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
732
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
603
733
|
|
|
604
734
|
Returns:
|
|
605
735
|
TClusterResponse[TFunctionStatsSingleNodeResponse]: A `Mapping` with two keys:
|
|
736
|
+
|
|
606
737
|
- `running_script` with information about the running script.
|
|
607
738
|
- `engines` with information about available engines and their stats.
|
|
608
|
-
|
|
739
|
+
|
|
740
|
+
See example for more details.
|
|
609
741
|
|
|
610
742
|
Examples:
|
|
611
743
|
>>> await client.function_stats(RandomNode())
|
|
@@ -636,7 +768,7 @@ class ClusterCommands(CoreCommands):
|
|
|
636
768
|
"""
|
|
637
769
|
Returns the serialized payload of all loaded libraries.
|
|
638
770
|
|
|
639
|
-
See https://valkey.io/commands/function-dump/ for more details.
|
|
771
|
+
See [valkey.io](https://valkey.io/commands/function-dump/) for more details.
|
|
640
772
|
|
|
641
773
|
Args:
|
|
642
774
|
route (Optional[Route]): The command will be routed to a random node, unless
|
|
@@ -669,7 +801,7 @@ class ClusterCommands(CoreCommands):
|
|
|
669
801
|
"""
|
|
670
802
|
Restores libraries from the serialized payload returned by the `function_dump` command.
|
|
671
803
|
|
|
672
|
-
See https://valkey.io/commands/function-restore/ for more details.
|
|
804
|
+
See [valkey.io](https://valkey.io/commands/function-restore/) for more details.
|
|
673
805
|
|
|
674
806
|
Args:
|
|
675
807
|
payload (bytes): The serialized data from the `function_dump` command.
|
|
@@ -706,24 +838,32 @@ class ClusterCommands(CoreCommands):
|
|
|
706
838
|
"""
|
|
707
839
|
Returns the server time.
|
|
708
840
|
|
|
709
|
-
See https://valkey.io/commands/time/ for more details.
|
|
841
|
+
See [valkey.io](https://valkey.io/commands/time/) for more details.
|
|
710
842
|
|
|
711
843
|
Args:
|
|
712
844
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
713
|
-
|
|
845
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
714
846
|
|
|
715
847
|
Returns:
|
|
716
848
|
TClusterResponse[Optional[bytes]]: The current server time as a two items `array`:
|
|
717
849
|
A Unix timestamp and the amount of microseconds already elapsed in the current second.
|
|
718
850
|
The returned `array` is in a [Unix timestamp, Microseconds already elapsed] format.
|
|
719
|
-
|
|
720
|
-
|
|
851
|
+
|
|
852
|
+
When specifying a route other than a single node, response will be::
|
|
853
|
+
|
|
854
|
+
{Address (bytes) : response (List[bytes]) , ... }
|
|
855
|
+
|
|
856
|
+
with type of Dict[bytes, List[bytes]].
|
|
721
857
|
|
|
722
858
|
Examples:
|
|
723
859
|
>>> await client.time()
|
|
724
860
|
[b'1710925775', b'913580']
|
|
725
861
|
>>> await client.time(AllNodes())
|
|
726
|
-
{
|
|
862
|
+
{
|
|
863
|
+
b'addr': [b'1710925775', b'913580'],
|
|
864
|
+
b'addr2': [b'1710925775', b'913580'],
|
|
865
|
+
b'addr3': [b'1710925775', b'913580']
|
|
866
|
+
}
|
|
727
867
|
"""
|
|
728
868
|
return cast(
|
|
729
869
|
TClusterResponse[List[bytes]],
|
|
@@ -734,7 +874,7 @@ class ClusterCommands(CoreCommands):
|
|
|
734
874
|
"""
|
|
735
875
|
Returns the Unix time of the last DB save timestamp or startup timestamp if no save was made since then.
|
|
736
876
|
|
|
737
|
-
See https://valkey.io/commands/lastsave for more details.
|
|
877
|
+
See [valkey.io](https://valkey.io/commands/lastsave) for more details.
|
|
738
878
|
|
|
739
879
|
Args:
|
|
740
880
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
@@ -742,15 +882,19 @@ class ClusterCommands(CoreCommands):
|
|
|
742
882
|
|
|
743
883
|
Returns:
|
|
744
884
|
TClusterResponse[int]: The Unix time of the last successful DB save.
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
885
|
+
|
|
886
|
+
If no route is provided, or a single node route is requested, returns an int representing the Unix time
|
|
887
|
+
of the last successful DB save.
|
|
888
|
+
|
|
889
|
+
Otherwise, returns a dict of [bytes , int] where each key contains the
|
|
890
|
+
address of the queried node and the value contains the Unix time of the last successful DB save.
|
|
748
891
|
|
|
749
892
|
Examples:
|
|
750
893
|
>>> await client.lastsave()
|
|
751
894
|
1710925775 # Unix time of the last DB save
|
|
752
895
|
>>> await client.lastsave(AllNodes())
|
|
753
|
-
{b'addr1': 1710925775, b'addr2': 1710925775, b'addr3': 1710925775} # Unix time of the last DB save on
|
|
896
|
+
{b'addr1': 1710925775, b'addr2': 1710925775, b'addr3': 1710925775} # Unix time of the last DB save on
|
|
897
|
+
# each node
|
|
754
898
|
"""
|
|
755
899
|
return cast(
|
|
756
900
|
TClusterResponse[int],
|
|
@@ -768,7 +912,9 @@ class ClusterCommands(CoreCommands):
|
|
|
768
912
|
This command aggregates PUBLISH and SPUBLISH commands functionalities.
|
|
769
913
|
The mode is selected using the 'sharded' parameter.
|
|
770
914
|
For both sharded and non-sharded mode, request is routed using hashed channel as key.
|
|
771
|
-
|
|
915
|
+
|
|
916
|
+
See [PUBLISH](https://valkey.io/commands/publish) and [SPUBLISH](https://valkey.io/commands/spublish)
|
|
917
|
+
for more details.
|
|
772
918
|
|
|
773
919
|
Args:
|
|
774
920
|
message (TEncodable): Message to publish.
|
|
@@ -796,15 +942,15 @@ class ClusterCommands(CoreCommands):
|
|
|
796
942
|
Lists the currently active shard channels.
|
|
797
943
|
The command is routed to all nodes, and aggregates the response to a single array.
|
|
798
944
|
|
|
799
|
-
See https://valkey.io/commands/pubsub-shardchannels for more details.
|
|
945
|
+
See [valkey.io](https://valkey.io/commands/pubsub-shardchannels) for more details.
|
|
800
946
|
|
|
801
947
|
Args:
|
|
802
948
|
pattern (Optional[TEncodable]): A glob-style pattern to match active shard channels.
|
|
803
|
-
|
|
949
|
+
If not provided, all active shard channels are returned.
|
|
804
950
|
|
|
805
951
|
Returns:
|
|
806
952
|
List[bytes]: A list of currently active shard channels matching the given pattern.
|
|
807
|
-
|
|
953
|
+
If no pattern is specified, all active shard channels are returned.
|
|
808
954
|
|
|
809
955
|
Examples:
|
|
810
956
|
>>> await client.pubsub_shardchannels()
|
|
@@ -826,13 +972,14 @@ class ClusterCommands(CoreCommands):
|
|
|
826
972
|
Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified shard channels.
|
|
827
973
|
|
|
828
974
|
Note that it is valid to call this command without channels. In this case, it will just return an empty map.
|
|
829
|
-
The command is routed to all nodes, and aggregates the response to a single map of the channels and their number of
|
|
975
|
+
The command is routed to all nodes, and aggregates the response to a single map of the channels and their number of
|
|
976
|
+
subscriptions.
|
|
830
977
|
|
|
831
|
-
See https://valkey.io/commands/pubsub-shardnumsub for more details.
|
|
978
|
+
See [valkey.io](https://valkey.io/commands/pubsub-shardnumsub) for more details.
|
|
832
979
|
|
|
833
980
|
Args:
|
|
834
981
|
channels (Optional[List[TEncodable]]): The list of shard channels to query for the number of subscribers.
|
|
835
|
-
|
|
982
|
+
If not provided, returns an empty map.
|
|
836
983
|
|
|
837
984
|
Returns:
|
|
838
985
|
Mapping[bytes, int]: A map where keys are the shard channel names and values are the number of subscribers.
|
|
@@ -857,7 +1004,7 @@ class ClusterCommands(CoreCommands):
|
|
|
857
1004
|
"""
|
|
858
1005
|
Deletes all the keys of all the existing databases. This command never fails.
|
|
859
1006
|
|
|
860
|
-
See https://valkey.io/commands/flushall for more details.
|
|
1007
|
+
See [valkey.io](https://valkey.io/commands/flushall) for more details.
|
|
861
1008
|
|
|
862
1009
|
Args:
|
|
863
1010
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -888,7 +1035,7 @@ class ClusterCommands(CoreCommands):
|
|
|
888
1035
|
"""
|
|
889
1036
|
Deletes all the keys of the currently selected database. This command never fails.
|
|
890
1037
|
|
|
891
|
-
See https://valkey.io/commands/flushdb for more details.
|
|
1038
|
+
See [valkey.io](https://valkey.io/commands/flushdb) for more details.
|
|
892
1039
|
|
|
893
1040
|
Args:
|
|
894
1041
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -925,7 +1072,7 @@ class ClusterCommands(CoreCommands):
|
|
|
925
1072
|
Copies the value stored at the `source` to the `destination` key. When `replace` is True,
|
|
926
1073
|
removes the `destination` key first if it already exists, otherwise performs no action.
|
|
927
1074
|
|
|
928
|
-
See https://valkey.io/commands/copy for more details.
|
|
1075
|
+
See [valkey.io](https://valkey.io/commands/copy) for more details.
|
|
929
1076
|
|
|
930
1077
|
Note:
|
|
931
1078
|
Both `source` and `destination` must map to the same hash slot.
|
|
@@ -964,20 +1111,26 @@ class ClusterCommands(CoreCommands):
|
|
|
964
1111
|
"""
|
|
965
1112
|
Displays a piece of generative computer art and the Valkey version.
|
|
966
1113
|
|
|
967
|
-
See https://valkey.io/commands/lolwut for more details.
|
|
1114
|
+
See [valkey.io](https://valkey.io/commands/lolwut) for more details.
|
|
968
1115
|
|
|
969
1116
|
Args:
|
|
970
1117
|
version (Optional[int]): Version of computer art to generate.
|
|
971
1118
|
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
|
|
972
|
-
|
|
973
|
-
For version `
|
|
1119
|
+
|
|
1120
|
+
- For version `5`, those are length of the line, number of squares per row, and number of squares per column.
|
|
1121
|
+
- For version `6`, those are number of columns and number of lines.
|
|
1122
|
+
|
|
974
1123
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
975
1124
|
in which case the client will route the command to the nodes defined by `route`.
|
|
976
1125
|
|
|
977
1126
|
Returns:
|
|
978
1127
|
TClusterResponse[bytes]: A piece of generative computer art along with the current Valkey version.
|
|
979
|
-
|
|
980
|
-
|
|
1128
|
+
|
|
1129
|
+
When specifying a route other than a single node, response will be::
|
|
1130
|
+
|
|
1131
|
+
{Address (bytes) : response (bytes) , ... }
|
|
1132
|
+
|
|
1133
|
+
with type of Dict[bytes, bytes].
|
|
981
1134
|
|
|
982
1135
|
Examples:
|
|
983
1136
|
>>> await client.lolwut(6, [40, 20], RandomNode());
|
|
@@ -998,7 +1151,7 @@ class ClusterCommands(CoreCommands):
|
|
|
998
1151
|
"""
|
|
999
1152
|
Returns a random existing key name.
|
|
1000
1153
|
|
|
1001
|
-
See https://valkey.io/commands/randomkey for more details.
|
|
1154
|
+
See [valkey.io](https://valkey.io/commands/randomkey) for more details.
|
|
1002
1155
|
|
|
1003
1156
|
Args:
|
|
1004
1157
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
@@ -1027,13 +1180,13 @@ class ClusterCommands(CoreCommands):
|
|
|
1027
1180
|
and acknowledged by at least `numreplicas` of replicas. If `timeout` is
|
|
1028
1181
|
reached, the command returns even if the specified number of replicas were not yet reached.
|
|
1029
1182
|
|
|
1030
|
-
See https://valkey.io/commands/wait for more details.
|
|
1183
|
+
See [valkey.io](https://valkey.io/commands/wait) for more details.
|
|
1031
1184
|
|
|
1032
1185
|
Args:
|
|
1033
1186
|
numreplicas (int): The number of replicas to reach.
|
|
1034
1187
|
timeout (int): The timeout value specified in milliseconds. A value of 0 will block indefinitely.
|
|
1035
1188
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
1036
|
-
|
|
1189
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
1037
1190
|
|
|
1038
1191
|
Returns:
|
|
1039
1192
|
int: The number of replicas reached by all the writes performed in the context of the current connection.
|
|
@@ -1041,7 +1194,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1041
1194
|
Examples:
|
|
1042
1195
|
>>> await client.set("key", "value");
|
|
1043
1196
|
>>> await client.wait(1, 1000);
|
|
1044
|
-
|
|
1197
|
+
# return 1 when a replica is reached or 0 if 1000ms is reached.
|
|
1045
1198
|
"""
|
|
1046
1199
|
args: List[TEncodable] = [str(numreplicas), str(timeout)]
|
|
1047
1200
|
return cast(
|
|
@@ -1054,7 +1207,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1054
1207
|
Flushes all the previously watched keys for a transaction. Executing a transaction will
|
|
1055
1208
|
automatically flush all previously watched keys.
|
|
1056
1209
|
|
|
1057
|
-
See https://valkey.io/commands/unwatch for more details.
|
|
1210
|
+
See [valkey.io](https://valkey.io/commands/unwatch) for more details.
|
|
1058
1211
|
|
|
1059
1212
|
Args:
|
|
1060
1213
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
@@ -1087,13 +1240,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1087
1240
|
This command is similar to the SCAN command but is designed to work in a cluster environment.
|
|
1088
1241
|
For each iteration, the new cursor object should be used to continue the scan.
|
|
1089
1242
|
Using the same cursor object for multiple iterations will result in the same keys or unexpected behavior.
|
|
1090
|
-
For more information about the Cluster Scan implementation, see
|
|
1243
|
+
For more information about the Cluster Scan implementation, see
|
|
1244
|
+
[Cluster Scan](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#cluster-scan).
|
|
1091
1245
|
|
|
1092
1246
|
Like the SCAN command, the method can be used to iterate over the keys in the database,
|
|
1093
1247
|
returning all keys the database has from when the scan started until the scan ends.
|
|
1094
1248
|
The same key can be returned in multiple scan iterations.
|
|
1095
1249
|
|
|
1096
|
-
See https://valkey.io/commands/scan/ for more details.
|
|
1250
|
+
See [valkey.io](https://valkey.io/commands/scan/) for more details.
|
|
1097
1251
|
|
|
1098
1252
|
Args:
|
|
1099
1253
|
cursor (ClusterScanCursor): The cursor object that wraps the scan state.
|
|
@@ -1104,13 +1258,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1104
1258
|
This parameter serves as a hint to the server on the number of steps to perform in each iteration.
|
|
1105
1259
|
The default value is 10.
|
|
1106
1260
|
type (Optional[ObjectType]): The type of object to scan for.
|
|
1107
|
-
allow_non_covered_slots (bool): If set to True, the scan will perform even if some slots are not covered by any
|
|
1261
|
+
allow_non_covered_slots (bool): If set to True, the scan will perform even if some slots are not covered by any
|
|
1262
|
+
node.
|
|
1108
1263
|
It's important to note that when set to True, the scan has no guarantee to cover all keys in the cluster,
|
|
1109
1264
|
and the method loses its way to validate the progress of the scan. Defaults to False.
|
|
1110
1265
|
|
|
1111
1266
|
Returns:
|
|
1112
1267
|
List[Union[ClusterScanCursor, List[TEncodable]]]: A list containing the next cursor and a list of keys,
|
|
1113
|
-
|
|
1268
|
+
formatted as [ClusterScanCursor, [key1, key2, ...]].
|
|
1114
1269
|
|
|
1115
1270
|
Examples:
|
|
1116
1271
|
>>> # Iterate over all keys in the cluster.
|
|
@@ -1123,7 +1278,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1123
1278
|
>>> print(all_keys) # [b'key1', b'key2', b'key3']
|
|
1124
1279
|
|
|
1125
1280
|
>>> # Iterate over keys matching the pattern "*key*".
|
|
1126
|
-
>>> await client.mset(
|
|
1281
|
+
>>> await client.mset(
|
|
1282
|
+
... {
|
|
1283
|
+
... b"key1": b"value1",
|
|
1284
|
+
... b"key2": b"value2",
|
|
1285
|
+
... b"not_my_key": b"value3",
|
|
1286
|
+
... b"something_else": b"value4"
|
|
1287
|
+
... }
|
|
1288
|
+
... )
|
|
1127
1289
|
>>> cursor = ClusterScanCursor()
|
|
1128
1290
|
>>> all_keys = []
|
|
1129
1291
|
>>> while not cursor.is_finished():
|
|
@@ -1158,7 +1320,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1158
1320
|
"""
|
|
1159
1321
|
Check existence of scripts in the script cache by their SHA1 digest.
|
|
1160
1322
|
|
|
1161
|
-
See https://valkey.io/commands/script-exists for more details.
|
|
1323
|
+
See [valkey.io](https://valkey.io/commands/script-exists) for more details.
|
|
1162
1324
|
|
|
1163
1325
|
Args:
|
|
1164
1326
|
sha1s (List[TEncodable]): List of SHA1 digests of the scripts to check.
|
|
@@ -1184,12 +1346,12 @@ class ClusterCommands(CoreCommands):
|
|
|
1184
1346
|
"""
|
|
1185
1347
|
Flush the Lua scripts cache.
|
|
1186
1348
|
|
|
1187
|
-
See https://valkey.io/commands/script-flush for more details.
|
|
1349
|
+
See [valkey.io](https://valkey.io/commands/script-flush) for more details.
|
|
1188
1350
|
|
|
1189
1351
|
Args:
|
|
1190
1352
|
mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
1191
|
-
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
1192
|
-
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1353
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
1354
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1193
1355
|
|
|
1194
1356
|
Returns:
|
|
1195
1357
|
TOK: A simple `OK` response.
|
|
@@ -1214,12 +1376,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1214
1376
|
Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
|
|
1215
1377
|
The command is routed to all nodes, and aggregates the response to a single array.
|
|
1216
1378
|
|
|
1217
|
-
See https://valkey.io/commands/script-kill for more details.
|
|
1379
|
+
See [valkey.io](https://valkey.io/commands/script-kill) for more details.
|
|
1380
|
+
|
|
1381
|
+
Args:
|
|
1382
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
1383
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1218
1384
|
|
|
1219
1385
|
Returns:
|
|
1220
1386
|
TOK: A simple `OK` response.
|
|
1221
|
-
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in which
|
|
1222
|
-
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1223
1387
|
|
|
1224
1388
|
Examples:
|
|
1225
1389
|
>>> await client.script_kill()
|
|
@@ -1240,9 +1404,11 @@ class ClusterCommands(CoreCommands):
|
|
|
1240
1404
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
1241
1405
|
After that, it will be invoked using the `EVALSHA` command.
|
|
1242
1406
|
|
|
1243
|
-
|
|
1407
|
+
Note:
|
|
1408
|
+
When in cluster mode, each `key` must map to the same hash slot.
|
|
1244
1409
|
|
|
1245
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1410
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1411
|
+
for more details.
|
|
1246
1412
|
|
|
1247
1413
|
Args:
|
|
1248
1414
|
script (Script): The Lua script to execute.
|
|
@@ -1273,13 +1439,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1273
1439
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
1274
1440
|
After that, it will be invoked using the `EVALSHA` command.
|
|
1275
1441
|
|
|
1276
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1442
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1443
|
+
for more details.
|
|
1277
1444
|
|
|
1278
1445
|
Args:
|
|
1279
1446
|
script (Script): The Lua script to execute.
|
|
1280
1447
|
args (Optional[List[TEncodable]]): The non-key arguments for the script.
|
|
1281
|
-
route (Optional[Route]): The command will be routed automatically to a random node, unless `route` is provided, in
|
|
1282
|
-
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1448
|
+
route (Optional[Route]): The command will be routed automatically to a random node, unless `route` is provided, in
|
|
1449
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1283
1450
|
|
|
1284
1451
|
Returns:
|
|
1285
1452
|
TResult: a value that depends on the script that was executed.
|