valkey-glide 1.3.5__cp39-cp39-macosx_11_0_arm64.whl → 2.2.2__cp39-cp39-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- glide/__init__.py +165 -107
- glide/async_commands/cluster_commands.py +318 -136
- glide/async_commands/core.py +1770 -992
- glide/async_commands/{server_modules/ft.py → ft.py} +91 -21
- glide/async_commands/{server_modules/glide_json.py → glide_json.py} +148 -134
- glide/async_commands/standalone_commands.py +203 -137
- glide/glide.cpython-39-darwin.so +0 -0
- glide/glide.pyi +26 -1
- glide/glide_client.py +352 -135
- glide/logger.py +34 -22
- glide/opentelemetry.py +185 -0
- glide_shared/__init__.py +330 -0
- glide_shared/commands/__init__.py +0 -0
- glide/async_commands/transaction.py → glide_shared/commands/batch.py +1839 -1017
- glide_shared/commands/batch_options.py +261 -0
- {glide/async_commands → glide_shared/commands}/bitmap.py +94 -85
- {glide/async_commands → glide_shared/commands}/command_args.py +7 -6
- glide_shared/commands/core_options.py +407 -0
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +18 -11
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +27 -13
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +16 -11
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +16 -8
- {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +160 -130
- glide_shared/commands/server_modules/json_options.py +93 -0
- {glide/async_commands → glide_shared/commands}/sorted_set.py +41 -31
- {glide/async_commands → glide_shared/commands}/stream.py +95 -88
- glide_shared/config.py +975 -0
- {glide → glide_shared}/constants.py +11 -7
- {glide → glide_shared}/exceptions.py +27 -1
- glide_shared/protobuf/command_request_pb2.py +56 -0
- glide_shared/protobuf/connection_request_pb2.py +56 -0
- {glide → glide_shared}/protobuf/response_pb2.py +6 -6
- {glide → glide_shared}/protobuf_codec.py +7 -6
- glide_shared/routes.py +161 -0
- valkey_glide-2.2.2.dist-info/METADATA +211 -0
- valkey_glide-2.2.2.dist-info/RECORD +40 -0
- glide/config.py +0 -590
- glide/protobuf/command_request_pb2.py +0 -54
- glide/protobuf/command_request_pb2.pyi +0 -1164
- glide/protobuf/connection_request_pb2.py +0 -52
- glide/protobuf/connection_request_pb2.pyi +0 -292
- glide/protobuf/response_pb2.pyi +0 -101
- glide/routes.py +0 -114
- valkey_glide-1.3.5.dist-info/METADATA +0 -125
- valkey_glide-1.3.5.dist-info/RECORD +0 -37
- {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
- {valkey_glide-1.3.5.dist-info → valkey_glide-2.2.2.dist-info}/WHEEL +0 -0
|
@@ -2,30 +2,30 @@
|
|
|
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.
|
|
8
|
-
from
|
|
9
|
-
|
|
7
|
+
from glide.glide import ClusterScanCursor, Script
|
|
8
|
+
from glide_shared.commands.batch import ClusterBatch
|
|
9
|
+
from glide_shared.commands.batch_options import ClusterBatchOptions
|
|
10
|
+
from glide_shared.commands.command_args import ObjectType
|
|
11
|
+
from glide_shared.commands.core_options import (
|
|
10
12
|
FlushMode,
|
|
11
13
|
FunctionRestorePolicy,
|
|
12
14
|
InfoSection,
|
|
13
|
-
_build_sort_args,
|
|
14
15
|
)
|
|
15
|
-
from
|
|
16
|
-
from glide.constants import (
|
|
16
|
+
from glide_shared.constants import (
|
|
17
17
|
TOK,
|
|
18
18
|
TClusterResponse,
|
|
19
19
|
TEncodable,
|
|
20
20
|
TFunctionListResponse,
|
|
21
21
|
TFunctionStatsSingleNodeResponse,
|
|
22
22
|
TResult,
|
|
23
|
-
TSingleNodeRoute,
|
|
24
23
|
)
|
|
25
|
-
from
|
|
26
|
-
from
|
|
24
|
+
from glide_shared.exceptions import RequestError
|
|
25
|
+
from glide_shared.protobuf.command_request_pb2 import RequestType
|
|
26
|
+
from glide_shared.routes import Route
|
|
27
27
|
|
|
28
|
-
from
|
|
28
|
+
from .core import CoreCommands
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
class ClusterCommands(CoreCommands):
|
|
@@ -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`.
|
|
@@ -919,13 +1066,19 @@ class ClusterCommands(CoreCommands):
|
|
|
919
1066
|
self,
|
|
920
1067
|
source: TEncodable,
|
|
921
1068
|
destination: TEncodable,
|
|
1069
|
+
# TODO next major release the arguments replace and destinationDB must have their order
|
|
1070
|
+
# swapped to align with the standalone order.
|
|
1071
|
+
# At the moment of the patch release 2.1.1. we can't have a breaking change
|
|
922
1072
|
replace: Optional[bool] = None,
|
|
1073
|
+
destinationDB: Optional[int] = None,
|
|
923
1074
|
) -> bool:
|
|
924
1075
|
"""
|
|
925
|
-
Copies the value stored at the `source` to the `destination` key.
|
|
926
|
-
|
|
1076
|
+
Copies the value stored at the `source` to the `destination` key. If `destinationDB`
|
|
1077
|
+
is specified, the value will be copied to the database specified by `destinationDB`,
|
|
1078
|
+
otherwise the current database will be used. When `replace` is True, removes the
|
|
1079
|
+
`destination` key first if it already exists, otherwise performs no action.
|
|
927
1080
|
|
|
928
|
-
See https://valkey.io/commands/copy for more details.
|
|
1081
|
+
See [valkey.io](https://valkey.io/commands/copy) for more details.
|
|
929
1082
|
|
|
930
1083
|
Note:
|
|
931
1084
|
Both `source` and `destination` must map to the same hash slot.
|
|
@@ -934,6 +1087,7 @@ class ClusterCommands(CoreCommands):
|
|
|
934
1087
|
source (TEncodable): The key to the source value.
|
|
935
1088
|
destination (TEncodable): The key where the value should be copied to.
|
|
936
1089
|
replace (Optional[bool]): If the destination key should be removed before copying the value to it.
|
|
1090
|
+
destinationDB (Optional[int]): The alternative logical database index for the destination key.
|
|
937
1091
|
|
|
938
1092
|
Returns:
|
|
939
1093
|
bool: True if the source was copied. Otherwise, returns False.
|
|
@@ -942,12 +1096,20 @@ class ClusterCommands(CoreCommands):
|
|
|
942
1096
|
>>> await client.set("source", "sheep")
|
|
943
1097
|
>>> await client.copy(b"source", b"destination")
|
|
944
1098
|
True # Source was copied
|
|
1099
|
+
>>> await client.copy(b"source", b"destination", destinationDB=1)
|
|
1100
|
+
True # Source was copied to DB 1
|
|
1101
|
+
>>> await client.select(1)
|
|
945
1102
|
>>> await client.get("destination")
|
|
946
1103
|
b"sheep"
|
|
947
1104
|
|
|
948
1105
|
Since: Valkey version 6.2.0.
|
|
1106
|
+
The destinationDB argument is available since Valkey 9.0.0
|
|
949
1107
|
"""
|
|
1108
|
+
|
|
1109
|
+
# Build command arguments
|
|
950
1110
|
args: List[TEncodable] = [source, destination]
|
|
1111
|
+
if destinationDB is not None:
|
|
1112
|
+
args.extend(["DB", str(destinationDB)])
|
|
951
1113
|
if replace is True:
|
|
952
1114
|
args.append("REPLACE")
|
|
953
1115
|
return cast(
|
|
@@ -964,20 +1126,26 @@ class ClusterCommands(CoreCommands):
|
|
|
964
1126
|
"""
|
|
965
1127
|
Displays a piece of generative computer art and the Valkey version.
|
|
966
1128
|
|
|
967
|
-
See https://valkey.io/commands/lolwut for more details.
|
|
1129
|
+
See [valkey.io](https://valkey.io/commands/lolwut) for more details.
|
|
968
1130
|
|
|
969
1131
|
Args:
|
|
970
1132
|
version (Optional[int]): Version of computer art to generate.
|
|
971
1133
|
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
|
|
972
|
-
|
|
973
|
-
For version `
|
|
1134
|
+
|
|
1135
|
+
- For version `5`, those are length of the line, number of squares per row, and number of squares per column.
|
|
1136
|
+
- For version `6`, those are number of columns and number of lines.
|
|
1137
|
+
|
|
974
1138
|
route (Optional[Route]): The command will be routed to a random node, unless `route` is provided,
|
|
975
1139
|
in which case the client will route the command to the nodes defined by `route`.
|
|
976
1140
|
|
|
977
1141
|
Returns:
|
|
978
1142
|
TClusterResponse[bytes]: A piece of generative computer art along with the current Valkey version.
|
|
979
|
-
|
|
980
|
-
|
|
1143
|
+
|
|
1144
|
+
When specifying a route other than a single node, response will be::
|
|
1145
|
+
|
|
1146
|
+
{Address (bytes) : response (bytes) , ... }
|
|
1147
|
+
|
|
1148
|
+
with type of Dict[bytes, bytes].
|
|
981
1149
|
|
|
982
1150
|
Examples:
|
|
983
1151
|
>>> await client.lolwut(6, [40, 20], RandomNode());
|
|
@@ -988,7 +1156,7 @@ class ClusterCommands(CoreCommands):
|
|
|
988
1156
|
args.extend(["VERSION", str(version)])
|
|
989
1157
|
if parameters:
|
|
990
1158
|
for var in parameters:
|
|
991
|
-
args.
|
|
1159
|
+
args.append(str(var))
|
|
992
1160
|
return cast(
|
|
993
1161
|
TClusterResponse[bytes],
|
|
994
1162
|
await self._execute_command(RequestType.Lolwut, args, route),
|
|
@@ -998,7 +1166,7 @@ class ClusterCommands(CoreCommands):
|
|
|
998
1166
|
"""
|
|
999
1167
|
Returns a random existing key name.
|
|
1000
1168
|
|
|
1001
|
-
See https://valkey.io/commands/randomkey for more details.
|
|
1169
|
+
See [valkey.io](https://valkey.io/commands/randomkey) for more details.
|
|
1002
1170
|
|
|
1003
1171
|
Args:
|
|
1004
1172
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
@@ -1027,13 +1195,13 @@ class ClusterCommands(CoreCommands):
|
|
|
1027
1195
|
and acknowledged by at least `numreplicas` of replicas. If `timeout` is
|
|
1028
1196
|
reached, the command returns even if the specified number of replicas were not yet reached.
|
|
1029
1197
|
|
|
1030
|
-
See https://valkey.io/commands/wait for more details.
|
|
1198
|
+
See [valkey.io](https://valkey.io/commands/wait) for more details.
|
|
1031
1199
|
|
|
1032
1200
|
Args:
|
|
1033
1201
|
numreplicas (int): The number of replicas to reach.
|
|
1034
1202
|
timeout (int): The timeout value specified in milliseconds. A value of 0 will block indefinitely.
|
|
1035
1203
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
1036
|
-
|
|
1204
|
+
in which case the client will route the command to the nodes defined by `route`.
|
|
1037
1205
|
|
|
1038
1206
|
Returns:
|
|
1039
1207
|
int: The number of replicas reached by all the writes performed in the context of the current connection.
|
|
@@ -1041,7 +1209,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1041
1209
|
Examples:
|
|
1042
1210
|
>>> await client.set("key", "value");
|
|
1043
1211
|
>>> await client.wait(1, 1000);
|
|
1044
|
-
|
|
1212
|
+
# return 1 when a replica is reached or 0 if 1000ms is reached.
|
|
1045
1213
|
"""
|
|
1046
1214
|
args: List[TEncodable] = [str(numreplicas), str(timeout)]
|
|
1047
1215
|
return cast(
|
|
@@ -1054,7 +1222,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1054
1222
|
Flushes all the previously watched keys for a transaction. Executing a transaction will
|
|
1055
1223
|
automatically flush all previously watched keys.
|
|
1056
1224
|
|
|
1057
|
-
See https://valkey.io/commands/unwatch for more details.
|
|
1225
|
+
See [valkey.io](https://valkey.io/commands/unwatch) for more details.
|
|
1058
1226
|
|
|
1059
1227
|
Args:
|
|
1060
1228
|
route (Optional[Route]): The command will be routed to all primary nodes, unless `route` is provided,
|
|
@@ -1087,13 +1255,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1087
1255
|
This command is similar to the SCAN command but is designed to work in a cluster environment.
|
|
1088
1256
|
For each iteration, the new cursor object should be used to continue the scan.
|
|
1089
1257
|
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
|
|
1258
|
+
For more information about the Cluster Scan implementation, see
|
|
1259
|
+
[Cluster Scan](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#cluster-scan).
|
|
1091
1260
|
|
|
1092
1261
|
Like the SCAN command, the method can be used to iterate over the keys in the database,
|
|
1093
1262
|
returning all keys the database has from when the scan started until the scan ends.
|
|
1094
1263
|
The same key can be returned in multiple scan iterations.
|
|
1095
1264
|
|
|
1096
|
-
See https://valkey.io/commands/scan/ for more details.
|
|
1265
|
+
See [valkey.io](https://valkey.io/commands/scan/) for more details.
|
|
1097
1266
|
|
|
1098
1267
|
Args:
|
|
1099
1268
|
cursor (ClusterScanCursor): The cursor object that wraps the scan state.
|
|
@@ -1104,13 +1273,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1104
1273
|
This parameter serves as a hint to the server on the number of steps to perform in each iteration.
|
|
1105
1274
|
The default value is 10.
|
|
1106
1275
|
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
|
|
1276
|
+
allow_non_covered_slots (bool): If set to True, the scan will perform even if some slots are not covered by any
|
|
1277
|
+
node.
|
|
1108
1278
|
It's important to note that when set to True, the scan has no guarantee to cover all keys in the cluster,
|
|
1109
1279
|
and the method loses its way to validate the progress of the scan. Defaults to False.
|
|
1110
1280
|
|
|
1111
1281
|
Returns:
|
|
1112
1282
|
List[Union[ClusterScanCursor, List[TEncodable]]]: A list containing the next cursor and a list of keys,
|
|
1113
|
-
|
|
1283
|
+
formatted as [ClusterScanCursor, [key1, key2, ...]].
|
|
1114
1284
|
|
|
1115
1285
|
Examples:
|
|
1116
1286
|
>>> # Iterate over all keys in the cluster.
|
|
@@ -1123,7 +1293,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1123
1293
|
>>> print(all_keys) # [b'key1', b'key2', b'key3']
|
|
1124
1294
|
|
|
1125
1295
|
>>> # Iterate over keys matching the pattern "*key*".
|
|
1126
|
-
>>> await client.mset(
|
|
1296
|
+
>>> await client.mset(
|
|
1297
|
+
... {
|
|
1298
|
+
... b"key1": b"value1",
|
|
1299
|
+
... b"key2": b"value2",
|
|
1300
|
+
... b"not_my_key": b"value3",
|
|
1301
|
+
... b"something_else": b"value4"
|
|
1302
|
+
... }
|
|
1303
|
+
... )
|
|
1127
1304
|
>>> cursor = ClusterScanCursor()
|
|
1128
1305
|
>>> all_keys = []
|
|
1129
1306
|
>>> while not cursor.is_finished():
|
|
@@ -1158,7 +1335,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1158
1335
|
"""
|
|
1159
1336
|
Check existence of scripts in the script cache by their SHA1 digest.
|
|
1160
1337
|
|
|
1161
|
-
See https://valkey.io/commands/script-exists for more details.
|
|
1338
|
+
See [valkey.io](https://valkey.io/commands/script-exists) for more details.
|
|
1162
1339
|
|
|
1163
1340
|
Args:
|
|
1164
1341
|
sha1s (List[TEncodable]): List of SHA1 digests of the scripts to check.
|
|
@@ -1184,12 +1361,12 @@ class ClusterCommands(CoreCommands):
|
|
|
1184
1361
|
"""
|
|
1185
1362
|
Flush the Lua scripts cache.
|
|
1186
1363
|
|
|
1187
|
-
See https://valkey.io/commands/script-flush for more details.
|
|
1364
|
+
See [valkey.io](https://valkey.io/commands/script-flush) for more details.
|
|
1188
1365
|
|
|
1189
1366
|
Args:
|
|
1190
1367
|
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.
|
|
1368
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
1369
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1193
1370
|
|
|
1194
1371
|
Returns:
|
|
1195
1372
|
TOK: A simple `OK` response.
|
|
@@ -1214,12 +1391,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1214
1391
|
Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
|
|
1215
1392
|
The command is routed to all nodes, and aggregates the response to a single array.
|
|
1216
1393
|
|
|
1217
|
-
See https://valkey.io/commands/script-kill for more details.
|
|
1394
|
+
See [valkey.io](https://valkey.io/commands/script-kill) for more details.
|
|
1395
|
+
|
|
1396
|
+
Args:
|
|
1397
|
+
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in
|
|
1398
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1218
1399
|
|
|
1219
1400
|
Returns:
|
|
1220
1401
|
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
1402
|
|
|
1224
1403
|
Examples:
|
|
1225
1404
|
>>> await client.script_kill()
|
|
@@ -1240,9 +1419,11 @@ class ClusterCommands(CoreCommands):
|
|
|
1240
1419
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
1241
1420
|
After that, it will be invoked using the `EVALSHA` command.
|
|
1242
1421
|
|
|
1243
|
-
|
|
1422
|
+
Note:
|
|
1423
|
+
When in cluster mode, each `key` must map to the same hash slot.
|
|
1244
1424
|
|
|
1245
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1425
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1426
|
+
for more details.
|
|
1246
1427
|
|
|
1247
1428
|
Args:
|
|
1248
1429
|
script (Script): The Lua script to execute.
|
|
@@ -1255,7 +1436,7 @@ class ClusterCommands(CoreCommands):
|
|
|
1255
1436
|
|
|
1256
1437
|
Examples:
|
|
1257
1438
|
>>> lua_script = Script("return { KEYS[1], ARGV[1] }")
|
|
1258
|
-
>>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"]
|
|
1439
|
+
>>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"])
|
|
1259
1440
|
[b"foo", b"bar"]
|
|
1260
1441
|
"""
|
|
1261
1442
|
return await self._execute_script(script.get_hash(), keys, args)
|
|
@@ -1273,13 +1454,14 @@ class ClusterCommands(CoreCommands):
|
|
|
1273
1454
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
1274
1455
|
After that, it will be invoked using the `EVALSHA` command.
|
|
1275
1456
|
|
|
1276
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1457
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1458
|
+
for more details.
|
|
1277
1459
|
|
|
1278
1460
|
Args:
|
|
1279
1461
|
script (Script): The Lua script to execute.
|
|
1280
1462
|
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.
|
|
1463
|
+
route (Optional[Route]): The command will be routed automatically to a random node, unless `route` is provided, in
|
|
1464
|
+
which case the client will route the command to the nodes defined by `route`. Defaults to None.
|
|
1283
1465
|
|
|
1284
1466
|
Returns:
|
|
1285
1467
|
TResult: a value that depends on the script that was executed.
|