valkey-glide 1.3.4rc6__cp310-cp310-macosx_11_0_arm64.whl → 2.0.0rc2__cp310-cp310-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of valkey-glide might be problematic. Click here for more details.
- glide/__init__.py +11 -7
- glide/async_commands/{transaction.py → batch.py} +1380 -970
- glide/async_commands/bitmap.py +94 -85
- glide/async_commands/cluster_commands.py +301 -122
- glide/async_commands/command_args.py +7 -6
- glide/async_commands/core.py +1281 -696
- glide/async_commands/server_modules/ft.py +83 -14
- glide/async_commands/server_modules/ft_options/ft_aggregate_options.py +15 -8
- glide/async_commands/server_modules/ft_options/ft_create_options.py +23 -11
- glide/async_commands/server_modules/ft_options/ft_profile_options.py +12 -7
- glide/async_commands/server_modules/ft_options/ft_search_options.py +12 -6
- glide/async_commands/server_modules/glide_json.py +134 -43
- glide/async_commands/server_modules/json_batch.py +157 -127
- glide/async_commands/sorted_set.py +39 -29
- glide/async_commands/standalone_commands.py +193 -96
- glide/async_commands/stream.py +94 -87
- glide/config.py +165 -105
- glide/constants.py +8 -4
- glide/glide.cpython-310-darwin.so +0 -0
- glide/glide_client.py +83 -10
- glide/logger.py +1 -1
- glide/protobuf/command_request_pb2.py +15 -15
- glide/protobuf/command_request_pb2.pyi +69 -46
- glide/protobuf/connection_request_pb2.py +15 -13
- glide/protobuf/connection_request_pb2.pyi +57 -29
- glide/protobuf/response_pb2.pyi +8 -9
- glide/protobuf_codec.py +7 -6
- glide/routes.py +16 -8
- {valkey_glide-1.3.4rc6.dist-info → valkey_glide-2.0.0rc2.dist-info}/METADATA +9 -5
- valkey_glide-2.0.0rc2.dist-info/RECORD +37 -0
- valkey_glide-1.3.4rc6.dist-info/RECORD +0 -37
- {valkey_glide-1.3.4rc6.dist-info → valkey_glide-2.0.0rc2.dist-info}/WHEEL +0 -0
|
@@ -2,17 +2,16 @@
|
|
|
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.command_args import ObjectType
|
|
8
9
|
from glide.async_commands.core import (
|
|
9
10
|
CoreCommands,
|
|
10
11
|
FlushMode,
|
|
11
12
|
FunctionRestorePolicy,
|
|
12
13
|
InfoSection,
|
|
13
|
-
_build_sort_args,
|
|
14
14
|
)
|
|
15
|
-
from glide.async_commands.transaction import ClusterTransaction
|
|
16
15
|
from glide.constants import (
|
|
17
16
|
TOK,
|
|
18
17
|
TClusterResponse,
|
|
@@ -37,13 +36,15 @@ class ClusterCommands(CoreCommands):
|
|
|
37
36
|
See the [Valkey GLIDE Wiki](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command)
|
|
38
37
|
for details on the restrictions and limitations of the custom command API.
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
For example - Return a list of all pub/sub clients from all nodes::
|
|
41
40
|
|
|
42
41
|
connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"], AllNodes())
|
|
42
|
+
|
|
43
43
|
Args:
|
|
44
44
|
command_args (List[TEncodable]): List of the command's arguments, where each argument is either a string or bytes.
|
|
45
45
|
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
|
|
46
|
+
route (Optional[Route]): The command will be routed automatically based on the passed command's default request
|
|
47
|
+
policy, unless `route` is provided, in which
|
|
47
48
|
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
48
49
|
|
|
49
50
|
Returns:
|
|
@@ -61,13 +62,14 @@ class ClusterCommands(CoreCommands):
|
|
|
61
62
|
) -> TClusterResponse[bytes]:
|
|
62
63
|
"""
|
|
63
64
|
Get information and statistics about the server.
|
|
64
|
-
|
|
65
|
+
|
|
66
|
+
See [valkey.io](https://valkey.io/commands/info/) for details.
|
|
65
67
|
|
|
66
68
|
Args:
|
|
67
69
|
sections (Optional[List[InfoSection]]): A list of InfoSection values specifying which sections of
|
|
68
|
-
|
|
70
|
+
information to retrieve. When no parameter is provided, the default option is assumed.
|
|
69
71
|
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided, in which
|
|
70
|
-
|
|
72
|
+
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
71
73
|
|
|
72
74
|
Returns:
|
|
73
75
|
TClusterResponse[bytes]: If a single node route is requested, returns a bytes string containing the information for
|
|
@@ -84,27 +86,139 @@ class ClusterCommands(CoreCommands):
|
|
|
84
86
|
|
|
85
87
|
async def exec(
|
|
86
88
|
self,
|
|
87
|
-
|
|
89
|
+
batch: ClusterBatch,
|
|
90
|
+
raise_on_error: bool,
|
|
88
91
|
route: Optional[TSingleNodeRoute] = None,
|
|
92
|
+
timeout: Optional[int] = None,
|
|
93
|
+
retry_server_error: bool = False,
|
|
94
|
+
retry_connection_error: bool = False,
|
|
89
95
|
) -> Optional[List[TResult]]:
|
|
90
96
|
"""
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
Executes a batch by processing the queued commands.
|
|
98
|
+
|
|
99
|
+
See [Valkey Transactions (Atomic Batches)](https://valkey.io/docs/topics/transactions/) for details.
|
|
100
|
+
See [Valkey Pipelines (Non-Atomic Batches)](https://valkey.io/docs/topics/pipelining/) for details.
|
|
101
|
+
|
|
102
|
+
#### Routing Behavior:
|
|
103
|
+
|
|
104
|
+
- If a `route` is specified:
|
|
105
|
+
- The entire batch is sent to the specified node.
|
|
106
|
+
|
|
107
|
+
- If no `route` is specified:
|
|
108
|
+
- Atomic batches (Transactions): Routed to the slot owner of the first key in the batch.
|
|
109
|
+
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 owning the corresponding
|
|
111
|
+
key's slot. If no key is present, routing follows the command's default request policy.
|
|
112
|
+
Multi-node commands are automatically split and dispatched to the appropriate nodes.
|
|
113
|
+
|
|
114
|
+
#### Behavior notes:
|
|
115
|
+
|
|
116
|
+
- Atomic Batches (Transactions): All key-based commands must map to the same hash slot.
|
|
117
|
+
If keys span different slots, the transaction will fail. If the transaction fails due to a
|
|
118
|
+
`WATCH` command, `exec` will return `None`.
|
|
119
|
+
|
|
120
|
+
#### Retry and Redirection:
|
|
121
|
+
|
|
122
|
+
- If a redirection error occurs:
|
|
123
|
+
- Atomic batches (Transactions): The entire transaction will be redirected.
|
|
124
|
+
- Non-atomic batches (Pipelines): Only commands that encountered redirection errors will be redirected.
|
|
125
|
+
|
|
126
|
+
- Retries for failures will be handled according to the `retry_server_error` and
|
|
127
|
+
`retry_connection_error` parameters.
|
|
93
128
|
|
|
94
129
|
Args:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
130
|
+
batch (ClusterBatch): A `ClusterBatch` object containing a list of commands to be executed.
|
|
131
|
+
raise_on_error (bool): Determines how errors are handled within the batch response. When set to
|
|
132
|
+
`True`, the first encountered error in the batch will be raised as a `RequestError`
|
|
133
|
+
exception after all retries and reconnections have been executed. When set to `False`,
|
|
134
|
+
errors will be included as part of the batch response array, allowing the caller to process both
|
|
135
|
+
successful and failed commands together. In this case, error details will be provided as
|
|
136
|
+
instances of `RequestError`.
|
|
137
|
+
route (Optional[TSingleNodeRoute]): Configures single-node routing for the batch request. The client
|
|
138
|
+
will send the batch to the specified node defined by `route`.
|
|
139
|
+
|
|
140
|
+
If a redirection error occurs:
|
|
141
|
+
- For Atomic Batches (Transactions), the entire transaction will be redirected.
|
|
142
|
+
- For Non-Atomic Batches (Pipelines), only the commands that encountered redirection errors
|
|
143
|
+
will be redirected.
|
|
144
|
+
timeout (Optional[int]): The duration in milliseconds that the client should wait for the batch request
|
|
145
|
+
to complete. This duration encompasses sending the request, awaiting a response from the server,
|
|
146
|
+
and any required reconnections or retries.
|
|
147
|
+
|
|
148
|
+
If the specified timeout is exceeded, a timeout error will be raised. If not explicitly set,
|
|
149
|
+
the client's default request timeout will be used.
|
|
150
|
+
retry_server_error (bool): If `True`, retriable server errors (e.g., `TRYAGAIN`) will trigger a retry.
|
|
151
|
+
Warning: Retrying server errors may cause commands targeting the same slot to execute out of order.
|
|
152
|
+
Note: Currently supported only for non-atomic batches. Recommended to increase timeout when enabled.
|
|
153
|
+
retry_connection_error (bool): If `True`, connection failures will trigger a retry. Warning:
|
|
154
|
+
Retrying connection errors may lead to duplicate executions, as it is unclear which commands have
|
|
155
|
+
already been processed. Note: Currently supported only for non-atomic batches. Recommended to increase
|
|
156
|
+
timeout when enabled.
|
|
99
157
|
|
|
100
158
|
Returns:
|
|
101
|
-
Optional[List[TResult]]: A list of results corresponding to the execution of each command
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
159
|
+
Optional[List[TResult]]: A list of results corresponding to the execution of each command in the batch.
|
|
160
|
+
If a command returns a value, it will be included in the list. If a command doesn't return a value,
|
|
161
|
+
the list entry will be `None`. If the batch failed due to a `WATCH` command, `exec` will return
|
|
162
|
+
`None`.
|
|
163
|
+
|
|
164
|
+
Examples:
|
|
165
|
+
# Example 1: Atomic Batch (Transaction)
|
|
166
|
+
>>> atomic_batch = ClusterBatch(is_atomic=True) # Atomic (Transaction)
|
|
167
|
+
>>> atomic_batch.set("key", "1")
|
|
168
|
+
>>> atomic_batch.incr("key")
|
|
169
|
+
>>> atomic_batch.get("key")
|
|
170
|
+
>>> atomic_result = await cluster_client.exec(atomic_batch, false)
|
|
171
|
+
>>> print(f"Atomic Batch Result: {atomic_result}")
|
|
172
|
+
# Expected Output: Atomic Batch Result: [OK, 2, 2]
|
|
173
|
+
|
|
174
|
+
# Example 2: Non-Atomic Batch (Pipeline)
|
|
175
|
+
>>> non_atomic_batch = ClusterBatch(is_atomic=False) # Non-Atomic (Pipeline)
|
|
176
|
+
>>> non_atomic_batch.set("key1", "value1")
|
|
177
|
+
>>> non_atomic_batch.set("key2", "value2")
|
|
178
|
+
>>> non_atomic_batch.get("key1")
|
|
179
|
+
>>> non_atomic_batch.get("key2")
|
|
180
|
+
>>> non_atomic_result = await cluster_client.exec(non_atomic_batch, false)
|
|
181
|
+
>>> print(f"Non-Atomic Batch Result: {non_atomic_result}")
|
|
182
|
+
# Expected Output: Non-Atomic Batch Result: [OK, OK, value1, value2]
|
|
183
|
+
|
|
184
|
+
# Example 3: Atomic batch with options
|
|
185
|
+
>>> atomic_batch = ClusterBatch(is_atomic=True)
|
|
186
|
+
>>> atomic_batch.set("key", "1")
|
|
187
|
+
>>> atomic_batch.incr("key")
|
|
188
|
+
>>> atomic_batch.get("key")
|
|
189
|
+
>>> atomic_result = await cluster_client.exec(
|
|
190
|
+
... atomic_batch,
|
|
191
|
+
... timeout=1000, # Set a timeout of 1000 milliseconds
|
|
192
|
+
... raise_on_error=False # Do not raise an error on failure
|
|
193
|
+
... )
|
|
194
|
+
>>> print(f"Atomic Batch Result: {atomic_result}")
|
|
195
|
+
# Output: Atomic Batch Result: [OK, 2, 2]
|
|
196
|
+
|
|
197
|
+
# Example 4: Non-atomic batch with retry options
|
|
198
|
+
>>> non_atomic_batch = ClusterBatch(is_atomic=False)
|
|
199
|
+
>>> non_atomic_batch.set("key1", "value1")
|
|
200
|
+
>>> non_atomic_batch.set("key2", "value2")
|
|
201
|
+
>>> non_atomic_batch.get("key1")
|
|
202
|
+
>>> non_atomic_batch.get("key2")
|
|
203
|
+
>>> non_atomic_result = await cluster_client.exec(
|
|
204
|
+
... non_atomic_batch,
|
|
205
|
+
... raise_on_error=False,
|
|
206
|
+
... retry_server_error=True,
|
|
207
|
+
... retry_connection_error=False
|
|
208
|
+
... )
|
|
209
|
+
>>> print(f"Non-Atomic Batch Result: {non_atomic_result}")
|
|
210
|
+
# Output: Non-Atomic Batch Result: [OK, OK, value1, value2]
|
|
211
|
+
"""
|
|
212
|
+
commands = batch.commands[:]
|
|
213
|
+
return await self._execute_batch(
|
|
214
|
+
commands,
|
|
215
|
+
batch.is_atomic,
|
|
216
|
+
raise_on_error,
|
|
217
|
+
retry_server_error,
|
|
218
|
+
retry_connection_error,
|
|
219
|
+
route,
|
|
220
|
+
timeout,
|
|
221
|
+
)
|
|
108
222
|
|
|
109
223
|
async def config_resetstat(
|
|
110
224
|
self,
|
|
@@ -112,11 +226,12 @@ class ClusterCommands(CoreCommands):
|
|
|
112
226
|
) -> TOK:
|
|
113
227
|
"""
|
|
114
228
|
Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
|
|
115
|
-
|
|
229
|
+
|
|
230
|
+
See [valkey.io](https://valkey.io/commands/config-resetstat/) for details.
|
|
116
231
|
|
|
117
232
|
Args:
|
|
118
|
-
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
119
|
-
|
|
233
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
234
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
120
235
|
|
|
121
236
|
Returns:
|
|
122
237
|
OK: Returns "OK" to confirm that the statistics were successfully reset.
|
|
@@ -131,11 +246,12 @@ class ClusterCommands(CoreCommands):
|
|
|
131
246
|
) -> TOK:
|
|
132
247
|
"""
|
|
133
248
|
Rewrite the configuration file with the current configuration.
|
|
134
|
-
|
|
249
|
+
|
|
250
|
+
See [valkey.io](https://valkey.io/commands/config-rewrite/) for details.
|
|
135
251
|
|
|
136
252
|
Args:
|
|
137
|
-
route (Optional[TRoute]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
138
|
-
|
|
253
|
+
route (Optional[TRoute]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
254
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
139
255
|
|
|
140
256
|
Returns:
|
|
141
257
|
OK: OK is returned when the configuration was rewritten properly. Otherwise an error is raised.
|
|
@@ -154,15 +270,18 @@ class ClusterCommands(CoreCommands):
|
|
|
154
270
|
) -> TClusterResponse[int]:
|
|
155
271
|
"""
|
|
156
272
|
Returns the current connection id.
|
|
157
|
-
|
|
273
|
+
|
|
274
|
+
See [valkey.io](https://valkey.io/commands/client-id/) for more information.
|
|
158
275
|
|
|
159
276
|
Args:
|
|
160
277
|
route (Optional[Route]): The command will be sent to a random node, unless `route` is provided, in which
|
|
161
|
-
|
|
278
|
+
case the client will route the command to the nodes defined by `route`.
|
|
162
279
|
|
|
163
280
|
Returns:
|
|
164
281
|
TClusterResponse[int]: The id of the client.
|
|
282
|
+
|
|
165
283
|
If a single node route is requested, returns a int representing the client's id.
|
|
284
|
+
|
|
166
285
|
Otherwise, returns a dict of [byte , int] where each key contains the address of
|
|
167
286
|
the queried node and the value contains the client's id.
|
|
168
287
|
"""
|
|
@@ -176,14 +295,14 @@ class ClusterCommands(CoreCommands):
|
|
|
176
295
|
) -> bytes:
|
|
177
296
|
"""
|
|
178
297
|
Ping the server.
|
|
179
|
-
|
|
298
|
+
|
|
299
|
+
See [valkey.io](https://valkey.io/commands/ping/) for more details.
|
|
180
300
|
|
|
181
301
|
Args:
|
|
182
302
|
message (Optional[TEncodable]): An optional message to include in the PING command. If not provided,
|
|
183
|
-
|
|
184
|
-
|
|
303
|
+
the server will respond with b"PONG". If provided, the server will respond with a copy of the message.
|
|
185
304
|
route (Optional[Route]): The command will be sent to all primaries, unless `route` is provided, in which
|
|
186
|
-
|
|
305
|
+
case the client will route the command to the nodes defined by `route`
|
|
187
306
|
|
|
188
307
|
Returns:
|
|
189
308
|
bytes: b'PONG' if `message` is not provided, otherwise return a copy of `message`.
|
|
@@ -205,18 +324,21 @@ class ClusterCommands(CoreCommands):
|
|
|
205
324
|
"""
|
|
206
325
|
Get the values of configuration parameters.
|
|
207
326
|
Starting from server version 7, command supports multiple parameters.
|
|
208
|
-
|
|
327
|
+
|
|
328
|
+
See [valkey.io](https://valkey.io/commands/config-get/) for details.
|
|
209
329
|
|
|
210
330
|
Args:
|
|
211
331
|
parameters (List[TEncodable]): A list of configuration parameter names to retrieve values for.
|
|
212
|
-
|
|
213
332
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
214
|
-
|
|
333
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
215
334
|
|
|
216
335
|
Returns:
|
|
217
336
|
TClusterResponse[Dict[bytes, bytes]]: A dictionary of values corresponding to the
|
|
218
337
|
configuration parameters.
|
|
219
|
-
When specifying a route other than a single node, response will be
|
|
338
|
+
When specifying a route other than a single node, response will be::
|
|
339
|
+
|
|
340
|
+
{Address (bytes) : response (Dict[bytes, bytes]) , ... }
|
|
341
|
+
|
|
220
342
|
with type of Dict[bytes, Dict[bytes, bytes]].
|
|
221
343
|
|
|
222
344
|
Examples:
|
|
@@ -238,14 +360,14 @@ class ClusterCommands(CoreCommands):
|
|
|
238
360
|
"""
|
|
239
361
|
Set configuration parameters to the specified values.
|
|
240
362
|
Starting from server version 7, command supports multiple parameters.
|
|
241
|
-
|
|
363
|
+
|
|
364
|
+
See [valkey.io](https://valkey.io/commands/config-set/) for details.
|
|
242
365
|
|
|
243
366
|
Args:
|
|
244
367
|
parameters_map (Mapping[TEncodable, TEncodable]): A map consisting of configuration
|
|
245
|
-
|
|
246
|
-
|
|
368
|
+
parameters and their respective values to set.
|
|
247
369
|
route (Optional[Route]): The command will be routed to all nodes, unless `route` is provided,
|
|
248
|
-
|
|
370
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
249
371
|
|
|
250
372
|
Returns:
|
|
251
373
|
OK: Returns OK if all configurations have been successfully set. Otherwise, raises an error.
|
|
@@ -267,17 +389,22 @@ class ClusterCommands(CoreCommands):
|
|
|
267
389
|
) -> TClusterResponse[Optional[bytes]]:
|
|
268
390
|
"""
|
|
269
391
|
Get the name of the connection to which the request is routed.
|
|
270
|
-
|
|
392
|
+
|
|
393
|
+
See [valkey.io](https://valkey.io/commands/client-getname/) for more details.
|
|
271
394
|
|
|
272
395
|
Args:
|
|
273
396
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
274
|
-
|
|
397
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
275
398
|
|
|
276
399
|
Returns:
|
|
277
400
|
TClusterResponse[Optional[bytes]]: The name of the client connection as a bytes string if a name is set,
|
|
278
401
|
or None if no name is assigned.
|
|
279
|
-
|
|
280
|
-
|
|
402
|
+
|
|
403
|
+
When specifying a route other than a single node, response will be::
|
|
404
|
+
|
|
405
|
+
{Address (bytes) : response (Optional[bytes]) , ... }
|
|
406
|
+
|
|
407
|
+
with type of Dict[str, Optional[str]].
|
|
281
408
|
|
|
282
409
|
Examples:
|
|
283
410
|
>>> await client.client_getname()
|
|
@@ -293,15 +420,18 @@ class ClusterCommands(CoreCommands):
|
|
|
293
420
|
async def dbsize(self, route: Optional[Route] = None) -> int:
|
|
294
421
|
"""
|
|
295
422
|
Returns the number of keys in the database.
|
|
296
|
-
|
|
423
|
+
|
|
424
|
+
See [valkey.io](https://valkey.io/commands/dbsize) for more details.
|
|
297
425
|
|
|
298
426
|
Args:
|
|
299
427
|
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided,
|
|
300
|
-
|
|
428
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
301
429
|
|
|
302
430
|
Returns:
|
|
303
431
|
int: The number of keys in the database.
|
|
304
|
-
|
|
432
|
+
|
|
433
|
+
In the case of routing the query to multiple nodes, returns the aggregated number of keys across the
|
|
434
|
+
different nodes.
|
|
305
435
|
|
|
306
436
|
Examples:
|
|
307
437
|
>>> await client.dbsize()
|
|
@@ -315,17 +445,21 @@ class ClusterCommands(CoreCommands):
|
|
|
315
445
|
"""
|
|
316
446
|
Echoes the provided `message` back.
|
|
317
447
|
|
|
318
|
-
See https://valkey.io/commands/echo for more details.
|
|
448
|
+
See [valkey.io](https://valkey.io/commands/echo) for more details.
|
|
319
449
|
|
|
320
450
|
Args:
|
|
321
451
|
message (TEncodable): The message to be echoed back.
|
|
322
452
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
323
|
-
|
|
453
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
324
454
|
|
|
325
455
|
Returns:
|
|
326
456
|
TClusterResponse[bytes]: The provided `message`.
|
|
327
|
-
|
|
328
|
-
|
|
457
|
+
|
|
458
|
+
When specifying a route other than a single node, response will be::
|
|
459
|
+
|
|
460
|
+
{Address (bytes) : response (bytes) , ... }
|
|
461
|
+
|
|
462
|
+
with type of Dict[bytes, bytes].
|
|
329
463
|
|
|
330
464
|
Examples:
|
|
331
465
|
>>> await client.echo(b"Valkey GLIDE")
|
|
@@ -347,7 +481,7 @@ class ClusterCommands(CoreCommands):
|
|
|
347
481
|
"""
|
|
348
482
|
Loads a library to Valkey.
|
|
349
483
|
|
|
350
|
-
See https://valkey.io/commands/function-load/ for more details.
|
|
484
|
+
See [valkey.io](https://valkey.io/commands/function-load/) for more details.
|
|
351
485
|
|
|
352
486
|
Args:
|
|
353
487
|
library_code (TEncodable): The source code that implements the library.
|
|
@@ -360,7 +494,7 @@ class ClusterCommands(CoreCommands):
|
|
|
360
494
|
bytes: The library name that was loaded.
|
|
361
495
|
|
|
362
496
|
Examples:
|
|
363
|
-
>>> code = "#!lua name=mylib
|
|
497
|
+
>>> code = "#!lua name=mylib \\n redis.register_function('myfunc', function(keys, args) return args[1] end)"
|
|
364
498
|
>>> await client.function_load(code, True, RandomNode())
|
|
365
499
|
b"mylib"
|
|
366
500
|
|
|
@@ -384,7 +518,7 @@ class ClusterCommands(CoreCommands):
|
|
|
384
518
|
"""
|
|
385
519
|
Returns information about the functions and libraries.
|
|
386
520
|
|
|
387
|
-
See https://valkey.io/commands/function-list/ for more details.
|
|
521
|
+
See [valkey.io](https://valkey.io/commands/function-list/) for more details.
|
|
388
522
|
|
|
389
523
|
Args:
|
|
390
524
|
library_name_pattern (Optional[TEncodable]): A wildcard pattern for matching library names.
|
|
@@ -406,7 +540,9 @@ class ClusterCommands(CoreCommands):
|
|
|
406
540
|
b"description": None,
|
|
407
541
|
b"flags": {b"no-writes"},
|
|
408
542
|
}],
|
|
409
|
-
b"library_code":
|
|
543
|
+
b"library_code":
|
|
544
|
+
b"#!lua name=mylib \\n redis.register_function('myfunc', function(keys, args) " \\
|
|
545
|
+
b"return args[1] end)"
|
|
410
546
|
}]
|
|
411
547
|
|
|
412
548
|
Since: Valkey 7.0.0.
|
|
@@ -431,7 +567,7 @@ class ClusterCommands(CoreCommands):
|
|
|
431
567
|
"""
|
|
432
568
|
Deletes all function libraries.
|
|
433
569
|
|
|
434
|
-
See https://valkey.io/commands/function-flush/ for more details.
|
|
570
|
+
See [valkey.io](https://valkey.io/commands/function-flush/) for more details.
|
|
435
571
|
|
|
436
572
|
Args:
|
|
437
573
|
mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -462,10 +598,10 @@ class ClusterCommands(CoreCommands):
|
|
|
462
598
|
"""
|
|
463
599
|
Deletes a library and all its functions.
|
|
464
600
|
|
|
465
|
-
See https://valkey.io/commands/function-delete/ for more details.
|
|
601
|
+
See [valkey.io](https://valkey.io/commands/function-delete/) for more details.
|
|
466
602
|
|
|
467
603
|
Args:
|
|
468
|
-
|
|
604
|
+
library_name (TEncodable): The library name to delete
|
|
469
605
|
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided,
|
|
470
606
|
in which case the client will route the command to the nodes defined by `route`.
|
|
471
607
|
|
|
@@ -492,7 +628,7 @@ class ClusterCommands(CoreCommands):
|
|
|
492
628
|
Kills a function that is currently executing.
|
|
493
629
|
This command only terminates read-only functions.
|
|
494
630
|
|
|
495
|
-
See https://valkey.io/commands/function-kill/ for more details.
|
|
631
|
+
See [valkey.io](https://valkey.io/commands/function-kill/) for more details.
|
|
496
632
|
|
|
497
633
|
Args:
|
|
498
634
|
route (Optional[Route]): The command will be routed to all nodes, unless `route` is provided,
|
|
@@ -524,7 +660,8 @@ class ClusterCommands(CoreCommands):
|
|
|
524
660
|
) -> TClusterResponse[TResult]:
|
|
525
661
|
"""
|
|
526
662
|
Invokes a previously loaded function.
|
|
527
|
-
|
|
663
|
+
|
|
664
|
+
See [valkey.io](https://valkey.io/commands/fcall/) for more details.
|
|
528
665
|
|
|
529
666
|
Args:
|
|
530
667
|
function (TEncodable): The function name.
|
|
@@ -534,13 +671,18 @@ class ClusterCommands(CoreCommands):
|
|
|
534
671
|
case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
535
672
|
|
|
536
673
|
Returns:
|
|
537
|
-
TClusterResponse[TResult]:
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
674
|
+
TClusterResponse[TResult]: If a single node route is requested,
|
|
675
|
+
returns a Optional[TResult] representing the function's return value.
|
|
676
|
+
|
|
677
|
+
Otherwise, returns a dict of [bytes , Optional[TResult]] where each key contains the address of
|
|
678
|
+
the queried node and the value contains the function's return value.
|
|
541
679
|
|
|
542
680
|
Example:
|
|
543
|
-
>>> await client.fcall(
|
|
681
|
+
>>> await client.fcall(
|
|
682
|
+
... "Deep_Thought",
|
|
683
|
+
... ["Answer", "to", "the", "Ultimate", "Question", "of", "Life,", "the", "Universe,", "and", "Everything"],
|
|
684
|
+
... RandomNode()
|
|
685
|
+
... )
|
|
544
686
|
b'new_value' # Returns the function's return value.
|
|
545
687
|
|
|
546
688
|
Since: Valkey version 7.0.0.
|
|
@@ -562,7 +704,7 @@ class ClusterCommands(CoreCommands):
|
|
|
562
704
|
"""
|
|
563
705
|
Invokes a previously loaded read-only function.
|
|
564
706
|
|
|
565
|
-
See https://valkey.io/commands/fcall_ro for more details.
|
|
707
|
+
See [valkey.io](https://valkey.io/commands/fcall_ro) for more details.
|
|
566
708
|
|
|
567
709
|
Args:
|
|
568
710
|
function (TEncodable): The function name.
|
|
@@ -595,17 +737,19 @@ class ClusterCommands(CoreCommands):
|
|
|
595
737
|
Returns information about the function that's currently running and information about the
|
|
596
738
|
available execution engines.
|
|
597
739
|
|
|
598
|
-
See https://valkey.io/commands/function-stats/ for more details
|
|
740
|
+
See [valkey.io](https://valkey.io/commands/function-stats/) for more details
|
|
599
741
|
|
|
600
742
|
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.
|
|
743
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
744
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
603
745
|
|
|
604
746
|
Returns:
|
|
605
747
|
TClusterResponse[TFunctionStatsSingleNodeResponse]: A `Mapping` with two keys:
|
|
748
|
+
|
|
606
749
|
- `running_script` with information about the running script.
|
|
607
750
|
- `engines` with information about available engines and their stats.
|
|
608
|
-
|
|
751
|
+
|
|
752
|
+
See example for more details.
|
|
609
753
|
|
|
610
754
|
Examples:
|
|
611
755
|
>>> await client.function_stats(RandomNode())
|
|
@@ -636,7 +780,7 @@ class ClusterCommands(CoreCommands):
|
|
|
636
780
|
"""
|
|
637
781
|
Returns the serialized payload of all loaded libraries.
|
|
638
782
|
|
|
639
|
-
See https://valkey.io/commands/function-dump/ for more details.
|
|
783
|
+
See [valkey.io](https://valkey.io/commands/function-dump/) for more details.
|
|
640
784
|
|
|
641
785
|
Args:
|
|
642
786
|
route (Optional[Route]): The command will be routed to a random node, unless
|
|
@@ -669,7 +813,7 @@ class ClusterCommands(CoreCommands):
|
|
|
669
813
|
"""
|
|
670
814
|
Restores libraries from the serialized payload returned by the `function_dump` command.
|
|
671
815
|
|
|
672
|
-
See https://valkey.io/commands/function-restore/ for more details.
|
|
816
|
+
See [valkey.io](https://valkey.io/commands/function-restore/) for more details.
|
|
673
817
|
|
|
674
818
|
Args:
|
|
675
819
|
payload (bytes): The serialized data from the `function_dump` command.
|
|
@@ -706,24 +850,32 @@ class ClusterCommands(CoreCommands):
|
|
|
706
850
|
"""
|
|
707
851
|
Returns the server time.
|
|
708
852
|
|
|
709
|
-
See https://valkey.io/commands/time/ for more details.
|
|
853
|
+
See [valkey.io](https://valkey.io/commands/time/) for more details.
|
|
710
854
|
|
|
711
855
|
Args:
|
|
712
856
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
713
|
-
|
|
857
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
714
858
|
|
|
715
859
|
Returns:
|
|
716
860
|
TClusterResponse[Optional[bytes]]: The current server time as a two items `array`:
|
|
717
861
|
A Unix timestamp and the amount of microseconds already elapsed in the current second.
|
|
718
862
|
The returned `array` is in a [Unix timestamp, Microseconds already elapsed] format.
|
|
719
|
-
|
|
720
|
-
|
|
863
|
+
|
|
864
|
+
When specifying a route other than a single node, response will be::
|
|
865
|
+
|
|
866
|
+
{Address (bytes) : response (List[bytes]) , ... }
|
|
867
|
+
|
|
868
|
+
with type of Dict[bytes, List[bytes]].
|
|
721
869
|
|
|
722
870
|
Examples:
|
|
723
871
|
>>> await client.time()
|
|
724
872
|
[b'1710925775', b'913580']
|
|
725
873
|
>>> await client.time(AllNodes())
|
|
726
|
-
{
|
|
874
|
+
{
|
|
875
|
+
b'addr': [b'1710925775', b'913580'],
|
|
876
|
+
b'addr2': [b'1710925775', b'913580'],
|
|
877
|
+
b'addr3': [b'1710925775', b'913580']
|
|
878
|
+
}
|
|
727
879
|
"""
|
|
728
880
|
return cast(
|
|
729
881
|
TClusterResponse[List[bytes]],
|
|
@@ -734,7 +886,7 @@ class ClusterCommands(CoreCommands):
|
|
|
734
886
|
"""
|
|
735
887
|
Returns the Unix time of the last DB save timestamp or startup timestamp if no save was made since then.
|
|
736
888
|
|
|
737
|
-
See https://valkey.io/commands/lastsave for more details.
|
|
889
|
+
See [valkey.io](https://valkey.io/commands/lastsave) for more details.
|
|
738
890
|
|
|
739
891
|
Args:
|
|
740
892
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
@@ -742,15 +894,19 @@ class ClusterCommands(CoreCommands):
|
|
|
742
894
|
|
|
743
895
|
Returns:
|
|
744
896
|
TClusterResponse[int]: The Unix time of the last successful DB save.
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
897
|
+
|
|
898
|
+
If no route is provided, or a single node route is requested, returns an int representing the Unix time
|
|
899
|
+
of the last successful DB save.
|
|
900
|
+
|
|
901
|
+
Otherwise, returns a dict of [bytes , int] where each key contains the
|
|
902
|
+
address of the queried node and the value contains the Unix time of the last successful DB save.
|
|
748
903
|
|
|
749
904
|
Examples:
|
|
750
905
|
>>> await client.lastsave()
|
|
751
906
|
1710925775 # Unix time of the last DB save
|
|
752
907
|
>>> await client.lastsave(AllNodes())
|
|
753
|
-
{b'addr1': 1710925775, b'addr2': 1710925775, b'addr3': 1710925775} # Unix time of the last DB save on
|
|
908
|
+
{b'addr1': 1710925775, b'addr2': 1710925775, b'addr3': 1710925775} # Unix time of the last DB save on
|
|
909
|
+
# each node
|
|
754
910
|
"""
|
|
755
911
|
return cast(
|
|
756
912
|
TClusterResponse[int],
|
|
@@ -768,7 +924,9 @@ class ClusterCommands(CoreCommands):
|
|
|
768
924
|
This command aggregates PUBLISH and SPUBLISH commands functionalities.
|
|
769
925
|
The mode is selected using the 'sharded' parameter.
|
|
770
926
|
For both sharded and non-sharded mode, request is routed using hashed channel as key.
|
|
771
|
-
|
|
927
|
+
|
|
928
|
+
See [PUBLISH](https://valkey.io/commands/publish) and [SPUBLISH](https://valkey.io/commands/spublish)
|
|
929
|
+
for more details.
|
|
772
930
|
|
|
773
931
|
Args:
|
|
774
932
|
message (TEncodable): Message to publish.
|
|
@@ -796,15 +954,15 @@ class ClusterCommands(CoreCommands):
|
|
|
796
954
|
Lists the currently active shard channels.
|
|
797
955
|
The command is routed to all nodes, and aggregates the response to a single array.
|
|
798
956
|
|
|
799
|
-
See https://valkey.io/commands/pubsub-shardchannels for more details.
|
|
957
|
+
See [valkey.io](https://valkey.io/commands/pubsub-shardchannels) for more details.
|
|
800
958
|
|
|
801
959
|
Args:
|
|
802
960
|
pattern (Optional[TEncodable]): A glob-style pattern to match active shard channels.
|
|
803
|
-
|
|
961
|
+
If not provided, all active shard channels are returned.
|
|
804
962
|
|
|
805
963
|
Returns:
|
|
806
964
|
List[bytes]: A list of currently active shard channels matching the given pattern.
|
|
807
|
-
|
|
965
|
+
If no pattern is specified, all active shard channels are returned.
|
|
808
966
|
|
|
809
967
|
Examples:
|
|
810
968
|
>>> await client.pubsub_shardchannels()
|
|
@@ -826,13 +984,14 @@ class ClusterCommands(CoreCommands):
|
|
|
826
984
|
Returns the number of subscribers (exclusive of clients subscribed to patterns) for the specified shard channels.
|
|
827
985
|
|
|
828
986
|
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
|
|
987
|
+
The command is routed to all nodes, and aggregates the response to a single map of the channels and their number of
|
|
988
|
+
subscriptions.
|
|
830
989
|
|
|
831
|
-
See https://valkey.io/commands/pubsub-shardnumsub for more details.
|
|
990
|
+
See [valkey.io](https://valkey.io/commands/pubsub-shardnumsub) for more details.
|
|
832
991
|
|
|
833
992
|
Args:
|
|
834
993
|
channels (Optional[List[TEncodable]]): The list of shard channels to query for the number of subscribers.
|
|
835
|
-
|
|
994
|
+
If not provided, returns an empty map.
|
|
836
995
|
|
|
837
996
|
Returns:
|
|
838
997
|
Mapping[bytes, int]: A map where keys are the shard channel names and values are the number of subscribers.
|
|
@@ -857,7 +1016,7 @@ class ClusterCommands(CoreCommands):
|
|
|
857
1016
|
"""
|
|
858
1017
|
Deletes all the keys of all the existing databases. This command never fails.
|
|
859
1018
|
|
|
860
|
-
See https://valkey.io/commands/flushall for more details.
|
|
1019
|
+
See [valkey.io](https://valkey.io/commands/flushall) for more details.
|
|
861
1020
|
|
|
862
1021
|
Args:
|
|
863
1022
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -888,7 +1047,7 @@ class ClusterCommands(CoreCommands):
|
|
|
888
1047
|
"""
|
|
889
1048
|
Deletes all the keys of the currently selected database. This command never fails.
|
|
890
1049
|
|
|
891
|
-
See https://valkey.io/commands/flushdb for more details.
|
|
1050
|
+
See [valkey.io](https://valkey.io/commands/flushdb) for more details.
|
|
892
1051
|
|
|
893
1052
|
Args:
|
|
894
1053
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -925,7 +1084,7 @@ class ClusterCommands(CoreCommands):
|
|
|
925
1084
|
Copies the value stored at the `source` to the `destination` key. When `replace` is True,
|
|
926
1085
|
removes the `destination` key first if it already exists, otherwise performs no action.
|
|
927
1086
|
|
|
928
|
-
See https://valkey.io/commands/copy for more details.
|
|
1087
|
+
See [valkey.io](https://valkey.io/commands/copy) for more details.
|
|
929
1088
|
|
|
930
1089
|
Note:
|
|
931
1090
|
Both `source` and `destination` must map to the same hash slot.
|
|
@@ -964,20 +1123,26 @@ class ClusterCommands(CoreCommands):
|
|
|
964
1123
|
"""
|
|
965
1124
|
Displays a piece of generative computer art and the Valkey version.
|
|
966
1125
|
|
|
967
|
-
See https://valkey.io/commands/lolwut for more details.
|
|
1126
|
+
See [valkey.io](https://valkey.io/commands/lolwut) for more details.
|
|
968
1127
|
|
|
969
1128
|
Args:
|
|
970
1129
|
version (Optional[int]): Version of computer art to generate.
|
|
971
1130
|
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
|
|
972
|
-
|
|
973
|
-
For version `
|
|
1131
|
+
|
|
1132
|
+
- For version `5`, those are length of the line, number of squares per row, and number of squares per column.
|
|
1133
|
+
- For version `6`, those are number of columns and number of lines.
|
|
1134
|
+
|
|
974
1135
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
975
1136
|
in which case the client will route the command to the nodes defined by `route`.
|
|
976
1137
|
|
|
977
1138
|
Returns:
|
|
978
1139
|
TClusterResponse[bytes]: A piece of generative computer art along with the current Valkey version.
|
|
979
|
-
|
|
980
|
-
|
|
1140
|
+
|
|
1141
|
+
When specifying a route other than a single node, response will be::
|
|
1142
|
+
|
|
1143
|
+
{Address (bytes) : response (bytes) , ... }
|
|
1144
|
+
|
|
1145
|
+
with type of Dict[bytes, bytes].
|
|
981
1146
|
|
|
982
1147
|
Examples:
|
|
983
1148
|
>>> await client.lolwut(6, [40, 20], RandomNode());
|
|
@@ -998,7 +1163,7 @@ class ClusterCommands(CoreCommands):
|
|
|
998
1163
|
"""
|
|
999
1164
|
Returns a random existing key name.
|
|
1000
1165
|
|
|
1001
|
-
See https://valkey.io/commands/randomkey for more details.
|
|
1166
|
+
See [valkey.io](https://valkey.io/commands/randomkey) for more details.
|
|
1002
1167
|
|
|
1003
1168
|
Args:
|
|
1004
1169
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
@@ -1027,13 +1192,13 @@ class ClusterCommands(CoreCommands):
|
|
|
1027
1192
|
and acknowledged by at least `numreplicas` of replicas. If `timeout` is
|
|
1028
1193
|
reached, the command returns even if the specified number of replicas were not yet reached.
|
|
1029
1194
|
|
|
1030
|
-
See https://valkey.io/commands/wait for more details.
|
|
1195
|
+
See [valkey.io](https://valkey.io/commands/wait) for more details.
|
|
1031
1196
|
|
|
1032
1197
|
Args:
|
|
1033
1198
|
numreplicas (int): The number of replicas to reach.
|
|
1034
1199
|
timeout (int): The timeout value specified in milliseconds. A value of 0 will block indefinitely.
|
|
1035
1200
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
1036
|
-
|
|
1201
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
1037
1202
|
|
|
1038
1203
|
Returns:
|
|
1039
1204
|
int: The number of replicas reached by all the writes performed in the context of the current connection.
|
|
@@ -1041,7 +1206,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1041
1206
|
Examples:
|
|
1042
1207
|
>>> await client.set("key", "value");
|
|
1043
1208
|
>>> await client.wait(1, 1000);
|
|
1044
|
-
|
|
1209
|
+
# return 1 when a replica is reached or 0 if 1000ms is reached.
|
|
1045
1210
|
"""
|
|
1046
1211
|
args: List[TEncodable] = [str(numreplicas), str(timeout)]
|
|
1047
1212
|
return cast(
|
|
@@ -1054,7 +1219,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1054
1219
|
Flushes all the previously watched keys for a transaction. Executing a transaction will
|
|
1055
1220
|
automatically flush all previously watched keys.
|
|
1056
1221
|
|
|
1057
|
-
See https://valkey.io/commands/unwatch for more details.
|
|
1222
|
+
See [valkey.io](https://valkey.io/commands/unwatch) for more details.
|
|
1058
1223
|
|
|
1059
1224
|
Args:
|
|
1060
1225
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
@@ -1087,13 +1252,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1087
1252
|
This command is similar to the SCAN command but is designed to work in a cluster environment.
|
|
1088
1253
|
For each iteration, the new cursor object should be used to continue the scan.
|
|
1089
1254
|
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
|
|
1255
|
+
For more information about the Cluster Scan implementation, see
|
|
1256
|
+
[Cluster Scan](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#cluster-scan).
|
|
1091
1257
|
|
|
1092
1258
|
Like the SCAN command, the method can be used to iterate over the keys in the database,
|
|
1093
1259
|
returning all keys the database has from when the scan started until the scan ends.
|
|
1094
1260
|
The same key can be returned in multiple scan iterations.
|
|
1095
1261
|
|
|
1096
|
-
See https://valkey.io/commands/scan/ for more details.
|
|
1262
|
+
See [valkey.io](https://valkey.io/commands/scan/) for more details.
|
|
1097
1263
|
|
|
1098
1264
|
Args:
|
|
1099
1265
|
cursor (ClusterScanCursor): The cursor object that wraps the scan state.
|
|
@@ -1104,13 +1270,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1104
1270
|
This parameter serves as a hint to the server on the number of steps to perform in each iteration.
|
|
1105
1271
|
The default value is 10.
|
|
1106
1272
|
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
|
|
1273
|
+
allow_non_covered_slots (bool): If set to True, the scan will perform even if some slots are not covered by any
|
|
1274
|
+
node.
|
|
1108
1275
|
It's important to note that when set to True, the scan has no guarantee to cover all keys in the cluster,
|
|
1109
1276
|
and the method loses its way to validate the progress of the scan. Defaults to False.
|
|
1110
1277
|
|
|
1111
1278
|
Returns:
|
|
1112
1279
|
List[Union[ClusterScanCursor, List[TEncodable]]]: A list containing the next cursor and a list of keys,
|
|
1113
|
-
|
|
1280
|
+
formatted as [ClusterScanCursor, [key1, key2, ...]].
|
|
1114
1281
|
|
|
1115
1282
|
Examples:
|
|
1116
1283
|
>>> # Iterate over all keys in the cluster.
|
|
@@ -1123,7 +1290,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1123
1290
|
>>> print(all_keys) # [b'key1', b'key2', b'key3']
|
|
1124
1291
|
|
|
1125
1292
|
>>> # Iterate over keys matching the pattern "*key*".
|
|
1126
|
-
>>> await client.mset(
|
|
1293
|
+
>>> await client.mset(
|
|
1294
|
+
... {
|
|
1295
|
+
... b"key1": b"value1",
|
|
1296
|
+
... b"key2": b"value2",
|
|
1297
|
+
... b"not_my_key": b"value3",
|
|
1298
|
+
... b"something_else": b"value4"
|
|
1299
|
+
... }
|
|
1300
|
+
... )
|
|
1127
1301
|
>>> cursor = ClusterScanCursor()
|
|
1128
1302
|
>>> all_keys = []
|
|
1129
1303
|
>>> while not cursor.is_finished():
|
|
@@ -1158,7 +1332,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1158
1332
|
"""
|
|
1159
1333
|
Check existence of scripts in the script cache by their SHA1 digest.
|
|
1160
1334
|
|
|
1161
|
-
See https://valkey.io/commands/script-exists for more details.
|
|
1335
|
+
See [valkey.io](https://valkey.io/commands/script-exists) for more details.
|
|
1162
1336
|
|
|
1163
1337
|
Args:
|
|
1164
1338
|
sha1s (List[TEncodable]): List of SHA1 digests of the scripts to check.
|
|
@@ -1184,12 +1358,12 @@ class ClusterCommands(CoreCommands):
|
|
|
1184
1358
|
"""
|
|
1185
1359
|
Flush the Lua scripts cache.
|
|
1186
1360
|
|
|
1187
|
-
See https://valkey.io/commands/script-flush for more details.
|
|
1361
|
+
See [valkey.io](https://valkey.io/commands/script-flush) for more details.
|
|
1188
1362
|
|
|
1189
1363
|
Args:
|
|
1190
1364
|
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.
|
|
1365
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
1366
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1193
1367
|
|
|
1194
1368
|
Returns:
|
|
1195
1369
|
TOK: A simple `OK` response.
|
|
@@ -1214,12 +1388,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1214
1388
|
Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
|
|
1215
1389
|
The command is routed to all nodes, and aggregates the response to a single array.
|
|
1216
1390
|
|
|
1217
|
-
See https://valkey.io/commands/script-kill for more details.
|
|
1391
|
+
See [valkey.io](https://valkey.io/commands/script-kill) for more details.
|
|
1392
|
+
|
|
1393
|
+
Args:
|
|
1394
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
1395
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1218
1396
|
|
|
1219
1397
|
Returns:
|
|
1220
1398
|
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
1399
|
|
|
1224
1400
|
Examples:
|
|
1225
1401
|
>>> await client.script_kill()
|
|
@@ -1240,9 +1416,11 @@ class ClusterCommands(CoreCommands):
|
|
|
1240
1416
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
1241
1417
|
After that, it will be invoked using the `EVALSHA` command.
|
|
1242
1418
|
|
|
1243
|
-
|
|
1419
|
+
Note:
|
|
1420
|
+
When in cluster mode, each `key` must map to the same hash slot.
|
|
1244
1421
|
|
|
1245
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1422
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1423
|
+
for more details.
|
|
1246
1424
|
|
|
1247
1425
|
Args:
|
|
1248
1426
|
script (Script): The Lua script to execute.
|
|
@@ -1273,13 +1451,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1273
1451
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
1274
1452
|
After that, it will be invoked using the `EVALSHA` command.
|
|
1275
1453
|
|
|
1276
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1454
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1455
|
+
for more details.
|
|
1277
1456
|
|
|
1278
1457
|
Args:
|
|
1279
1458
|
script (Script): The Lua script to execute.
|
|
1280
1459
|
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.
|
|
1460
|
+
route (Optional[Route]): The command will be routed automatically to a random node, unless `route` is provided, in
|
|
1461
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1283
1462
|
|
|
1284
1463
|
Returns:
|
|
1285
1464
|
TResult: a value that depends on the script that was executed.
|