valkey-glide 1.3.4rc5__cp313-cp313-macosx_11_0_arm64.whl → 2.0.0rc2__cp313-cp313-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of valkey-glide might be problematic. Click here for more details.
- glide/__init__.py +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-313-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.4rc5.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.4rc5.dist-info/RECORD +0 -37
- {valkey_glide-1.3.4rc5.dist-info → valkey_glide-2.0.0rc2.dist-info}/WHEEL +0 -0
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import Dict, List, Mapping, Optional, Union, cast
|
|
6
6
|
|
|
7
|
+
from glide.async_commands.batch import Batch
|
|
7
8
|
from glide.async_commands.command_args import ObjectType
|
|
8
9
|
from glide.async_commands.core import (
|
|
9
10
|
CoreCommands,
|
|
@@ -11,7 +12,6 @@ from glide.async_commands.core import (
|
|
|
11
12
|
FunctionRestorePolicy,
|
|
12
13
|
InfoSection,
|
|
13
14
|
)
|
|
14
|
-
from glide.async_commands.transaction import Transaction
|
|
15
15
|
from glide.constants import (
|
|
16
16
|
TOK,
|
|
17
17
|
TEncodable,
|
|
@@ -31,15 +31,16 @@ class StandaloneCommands(CoreCommands):
|
|
|
31
31
|
See the [Valkey GLIDE Wiki](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command)
|
|
32
32
|
for details on the restrictions and limitations of the custom command API.
|
|
33
33
|
|
|
34
|
-
@example - Return a list of all pub/sub clients:
|
|
35
|
-
|
|
36
|
-
connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"])
|
|
37
34
|
Args:
|
|
38
35
|
command_args (List[TEncodable]): List of the command's arguments, where each argument is either a string or bytes.
|
|
39
36
|
Every part of the command, including the command name and subcommands, should be added as a separate value in args.
|
|
40
37
|
|
|
41
38
|
Returns:
|
|
42
39
|
TResult: The returning value depends on the executed command.
|
|
40
|
+
|
|
41
|
+
Example:
|
|
42
|
+
>>> connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"])
|
|
43
|
+
|
|
43
44
|
"""
|
|
44
45
|
return await self._execute_command(RequestType.CustomCommand, command_args)
|
|
45
46
|
|
|
@@ -49,12 +50,12 @@ class StandaloneCommands(CoreCommands):
|
|
|
49
50
|
) -> bytes:
|
|
50
51
|
"""
|
|
51
52
|
Get information and statistics about the server.
|
|
52
|
-
|
|
53
|
+
|
|
54
|
+
See [valkey.io](https://valkey.io/commands/info/) for details.
|
|
53
55
|
|
|
54
56
|
Args:
|
|
55
57
|
sections (Optional[List[InfoSection]]): A list of InfoSection values specifying which sections of
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
information to retrieve. When no parameter is provided, the default option is assumed.
|
|
58
59
|
|
|
59
60
|
Returns:
|
|
60
61
|
bytes: Returns bytes containing the information for the sections requested.
|
|
@@ -66,28 +67,96 @@ class StandaloneCommands(CoreCommands):
|
|
|
66
67
|
|
|
67
68
|
async def exec(
|
|
68
69
|
self,
|
|
69
|
-
|
|
70
|
+
batch: Batch,
|
|
71
|
+
raise_on_error: bool,
|
|
72
|
+
timeout: Optional[int] = None,
|
|
70
73
|
) -> Optional[List[TResult]]:
|
|
71
74
|
"""
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
Executes a batch by processing the queued commands.
|
|
76
|
+
|
|
77
|
+
See [Valkey Transactions (Atomic Batches)](https://valkey.io/docs/topics/transactions/) and
|
|
78
|
+
[Valkey Pipelines (Non-Atomic Batches)](https://valkey.io/docs/topics/pipelining/) for details.
|
|
79
|
+
|
|
80
|
+
Notes:
|
|
81
|
+
- Atomic Batches - Transactions: If the transaction fails due to a ``WATCH`` command,
|
|
82
|
+
``exec`` will return ``None``.
|
|
74
83
|
|
|
75
84
|
Args:
|
|
76
|
-
|
|
85
|
+
batch (Batch): A ``Batch`` containing the commands to execute.
|
|
86
|
+
raise_on_error (bool): Determines how errors are handled within the batch response.
|
|
87
|
+
When set to ``True``, the first encountered error in the batch will be raised as a
|
|
88
|
+
``RequestError`` exception after all retries and reconnections have been executed.
|
|
89
|
+
When set to ``False``, errors will be included as part of the batch response array, allowing
|
|
90
|
+
the caller to process both successful and failed commands together. In this case, error details
|
|
91
|
+
will be provided as instances of ``RequestError``.
|
|
92
|
+
timeout (Optional[int]): The duration in milliseconds that the client should wait for the batch request
|
|
93
|
+
to complete. This duration encompasses sending the request, awaiting a response from the server, and any
|
|
94
|
+
required reconnections or retries. If the specified timeout is exceeded for the request,
|
|
95
|
+
a timeout error will be raised. If not explicitly set, the client's default request timeout will be used.
|
|
77
96
|
|
|
78
97
|
Returns:
|
|
79
|
-
Optional[List[TResult]]:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
Optional[List[TResult]]: An array of results, where each entry corresponds to a command's execution result.
|
|
99
|
+
If the batch fails due to a ``WATCH`` command, ``exec`` will return ``None``.
|
|
100
|
+
|
|
101
|
+
Example (Atomic Batch - Transaction):
|
|
102
|
+
>>> transaction = Batch(is_atomic=True) # Atomic (Transaction)
|
|
103
|
+
>>> transaction.set("key", "1")
|
|
104
|
+
>>> transaction.incr("key")
|
|
105
|
+
>>> transaction.get("key")
|
|
106
|
+
>>> result = await client.exec(transaction, raise_on_error=True)
|
|
107
|
+
>>> print(f"Transaction Batch Result: {result}")
|
|
108
|
+
# Expected Output: Transaction Batch Result: [OK, 2, b'2']
|
|
109
|
+
|
|
110
|
+
Example (Non-Atomic Batch - Pipeline):
|
|
111
|
+
>>> pipeline = Batch(is_atomic=False) # Non-Atomic (Pipeline)
|
|
112
|
+
>>> pipeline.set("key1", "value1")
|
|
113
|
+
>>> pipeline.set("key2", "value2")
|
|
114
|
+
>>> pipeline.get("key1")
|
|
115
|
+
>>> pipeline.get("key2")
|
|
116
|
+
>>> result = await client.exec(pipeline, raise_on_error=True)
|
|
117
|
+
>>> print(f"Pipeline Batch Result: {result}")
|
|
118
|
+
# Expected Output: Pipeline Batch Result: [OK, OK, b'value1', b'value2']
|
|
119
|
+
|
|
120
|
+
Example (Atomic Batch - Transaction with options):
|
|
121
|
+
>>> transaction = Batch(is_atomic=True)
|
|
122
|
+
>>> transaction.set("key", "1")
|
|
123
|
+
>>> transaction.incr("key")
|
|
124
|
+
>>> transaction.custom_command(["get", "key"])
|
|
125
|
+
>>> result = await client.exec(
|
|
126
|
+
... transaction,
|
|
127
|
+
... raise_on_error=False, # Do not raise an error on failure
|
|
128
|
+
... timeout=1000 # Set a timeout of 1000 milliseconds
|
|
129
|
+
... )
|
|
130
|
+
>>> print(f"Transaction Result: {result}")
|
|
131
|
+
# Expected Output: Transaction Result: [OK, 2, b'2']
|
|
132
|
+
|
|
133
|
+
Example (Non-Atomic Batch - Pipeline with options):
|
|
134
|
+
>>> pipeline = Batch(is_atomic=False)
|
|
135
|
+
>>> pipeline.custom_command(["set", "key1", "value1"])
|
|
136
|
+
>>> pipeline.custom_command(["set", "key2", "value2"])
|
|
137
|
+
>>> pipeline.custom_command(["get", "key1"])
|
|
138
|
+
>>> pipeline.custom_command(["get", "key2"])
|
|
139
|
+
>>> result = await client.exec(
|
|
140
|
+
... pipeline,
|
|
141
|
+
... raise_on_error=False, # Do not raise an error on failure
|
|
142
|
+
... timeout=1000 # Set a timeout of 1000 milliseconds
|
|
143
|
+
... )
|
|
144
|
+
>>> print(f"Pipeline Result: {result}")
|
|
145
|
+
# Expected Output: Pipeline Result: [OK, OK, b'value1', b'value2']
|
|
146
|
+
"""
|
|
147
|
+
commands = batch.commands[:]
|
|
148
|
+
return await self._execute_batch(
|
|
149
|
+
commands,
|
|
150
|
+
is_atomic=batch.is_atomic,
|
|
151
|
+
raise_on_error=raise_on_error,
|
|
152
|
+
timeout=timeout,
|
|
153
|
+
)
|
|
86
154
|
|
|
87
155
|
async def select(self, index: int) -> TOK:
|
|
88
156
|
"""
|
|
89
157
|
Change the currently selected database.
|
|
90
|
-
|
|
158
|
+
|
|
159
|
+
See [valkey.io](https://valkey.io/commands/select/) for details.
|
|
91
160
|
|
|
92
161
|
Args:
|
|
93
162
|
index (int): The index of the database to select.
|
|
@@ -100,7 +169,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
100
169
|
async def config_resetstat(self) -> TOK:
|
|
101
170
|
"""
|
|
102
171
|
Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
|
|
103
|
-
|
|
172
|
+
|
|
173
|
+
See [valkey.io](https://valkey.io/commands/config-resetstat/) for details.
|
|
104
174
|
|
|
105
175
|
Returns:
|
|
106
176
|
OK: Returns "OK" to confirm that the statistics were successfully reset.
|
|
@@ -110,10 +180,13 @@ class StandaloneCommands(CoreCommands):
|
|
|
110
180
|
async def config_rewrite(self) -> TOK:
|
|
111
181
|
"""
|
|
112
182
|
Rewrite the configuration file with the current configuration.
|
|
113
|
-
|
|
183
|
+
|
|
184
|
+
See [valkey.io](https://valkey.io/commands/config-rewrite/) for details.
|
|
114
185
|
|
|
115
186
|
Returns:
|
|
116
|
-
OK: OK is returned when the configuration was rewritten properly.
|
|
187
|
+
OK: OK is returned when the configuration was rewritten properly.
|
|
188
|
+
|
|
189
|
+
Otherwise, an error is raised.
|
|
117
190
|
"""
|
|
118
191
|
return cast(TOK, await self._execute_command(RequestType.ConfigRewrite, []))
|
|
119
192
|
|
|
@@ -122,7 +195,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
122
195
|
) -> int:
|
|
123
196
|
"""
|
|
124
197
|
Returns the current connection id.
|
|
125
|
-
|
|
198
|
+
|
|
199
|
+
See [valkey.io](https://valkey.io/commands/client-id/) for more information.
|
|
126
200
|
|
|
127
201
|
Returns:
|
|
128
202
|
int: the id of the client.
|
|
@@ -132,14 +206,17 @@ class StandaloneCommands(CoreCommands):
|
|
|
132
206
|
async def ping(self, message: Optional[TEncodable] = None) -> bytes:
|
|
133
207
|
"""
|
|
134
208
|
Ping the server.
|
|
135
|
-
|
|
209
|
+
|
|
210
|
+
See [valkey.io](https://valkey.io/commands/ping/) for more details.
|
|
136
211
|
|
|
137
212
|
Args:
|
|
138
|
-
|
|
139
|
-
|
|
213
|
+
message (Optional[TEncodable]): An optional message to include in the PING command. If not provided,
|
|
214
|
+
the server will respond with b"PONG". If provided, the server will respond with a copy of the message.
|
|
140
215
|
|
|
141
216
|
Returns:
|
|
142
|
-
|
|
217
|
+
bytes: b"PONG" if `message` is not provided.
|
|
218
|
+
|
|
219
|
+
Otherwise return a copy of `message`.
|
|
143
220
|
|
|
144
221
|
Examples:
|
|
145
222
|
>>> await client.ping()
|
|
@@ -153,8 +230,9 @@ class StandaloneCommands(CoreCommands):
|
|
|
153
230
|
async def config_get(self, parameters: List[TEncodable]) -> Dict[bytes, bytes]:
|
|
154
231
|
"""
|
|
155
232
|
Get the values of configuration parameters.
|
|
156
|
-
Starting from server version 7, command supports multiple parameters
|
|
157
|
-
|
|
233
|
+
Starting from server version 7, command supports multiple parameters
|
|
234
|
+
|
|
235
|
+
See [valkey.io](https://valkey.io/commands/config-get/) for details.
|
|
158
236
|
|
|
159
237
|
Args:
|
|
160
238
|
parameters (List[TEncodable]): A list of configuration parameter names to retrieve values for.
|
|
@@ -177,14 +255,17 @@ class StandaloneCommands(CoreCommands):
|
|
|
177
255
|
"""
|
|
178
256
|
Set configuration parameters to the specified values.
|
|
179
257
|
Starting from server version 7, command supports multiple parameters.
|
|
180
|
-
|
|
258
|
+
|
|
259
|
+
See [valkey.io](https://valkey.io/commands/config-set/) for details.
|
|
181
260
|
|
|
182
261
|
Args:
|
|
183
262
|
parameters_map (Mapping[TEncodable, TEncodable]): A map consisting of configuration
|
|
184
|
-
|
|
263
|
+
parameters and their respective values to set.
|
|
185
264
|
|
|
186
265
|
Returns:
|
|
187
|
-
OK: Returns OK if all configurations have been successfully set.
|
|
266
|
+
OK: Returns OK if all configurations have been successfully set.
|
|
267
|
+
|
|
268
|
+
Otherwise, raises an error.
|
|
188
269
|
|
|
189
270
|
Examples:
|
|
190
271
|
>>> config_set({"timeout": "1000", "maxmemory": "1GB"})
|
|
@@ -198,11 +279,13 @@ class StandaloneCommands(CoreCommands):
|
|
|
198
279
|
async def client_getname(self) -> Optional[bytes]:
|
|
199
280
|
"""
|
|
200
281
|
Get the name of the primary's connection.
|
|
201
|
-
|
|
282
|
+
|
|
283
|
+
See [valkey.io](https://valkey.io/commands/client-getname/) for more details.
|
|
202
284
|
|
|
203
285
|
Returns:
|
|
204
|
-
Optional[bytes]: Returns the name of the client connection as a byte string if a name is set
|
|
205
|
-
|
|
286
|
+
Optional[bytes]: Returns the name of the client connection as a byte string if a name is set.
|
|
287
|
+
|
|
288
|
+
`None` if no name is assigned.
|
|
206
289
|
|
|
207
290
|
Examples:
|
|
208
291
|
>>> await client.client_getname()
|
|
@@ -215,7 +298,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
215
298
|
async def dbsize(self) -> int:
|
|
216
299
|
"""
|
|
217
300
|
Returns the number of keys in the currently selected database.
|
|
218
|
-
|
|
301
|
+
|
|
302
|
+
See [valkey.io](https://valkey.io/commands/dbsize) for more details.
|
|
219
303
|
|
|
220
304
|
Returns:
|
|
221
305
|
int: The number of keys in the currently selected database.
|
|
@@ -230,7 +314,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
230
314
|
"""
|
|
231
315
|
Echoes the provided `message` back.
|
|
232
316
|
|
|
233
|
-
See https://valkey.io/commands/echo for more details.
|
|
317
|
+
See [valkey.io](https://valkey.io/commands/echo) for more details.
|
|
234
318
|
|
|
235
319
|
Args:
|
|
236
320
|
message (TEncodable): The message to be echoed back.
|
|
@@ -250,7 +334,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
250
334
|
"""
|
|
251
335
|
Loads a library to Valkey.
|
|
252
336
|
|
|
253
|
-
See https://valkey.io/commands/function-load/ for more details.
|
|
337
|
+
See [valkey.io](https://valkey.io/commands/function-load/) for more details.
|
|
254
338
|
|
|
255
339
|
Args:
|
|
256
340
|
library_code (TEncodable): The source code that implements the library.
|
|
@@ -261,7 +345,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
261
345
|
bytes: The library name that was loaded.
|
|
262
346
|
|
|
263
347
|
Examples:
|
|
264
|
-
>>> code = "#!lua name=mylib
|
|
348
|
+
>>> code = "#!lua name=mylib \\n redis.register_function('myfunc', function(keys, args) return args[1] end)"
|
|
265
349
|
>>> await client.function_load(code, True)
|
|
266
350
|
b"mylib"
|
|
267
351
|
|
|
@@ -281,7 +365,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
281
365
|
"""
|
|
282
366
|
Returns information about the functions and libraries.
|
|
283
367
|
|
|
284
|
-
See https://valkey.io/commands/function-list/ for more details.
|
|
368
|
+
See [valkey.io](https://valkey.io/commands/function-list/) for more details.
|
|
285
369
|
|
|
286
370
|
Args:
|
|
287
371
|
library_name_pattern (Optional[TEncodable]): A wildcard pattern for matching library names.
|
|
@@ -289,7 +373,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
289
373
|
|
|
290
374
|
Returns:
|
|
291
375
|
TFunctionListResponse: Info about all or
|
|
292
|
-
|
|
376
|
+
selected libraries and their functions.
|
|
293
377
|
|
|
294
378
|
Examples:
|
|
295
379
|
>>> response = await client.function_list("myLib?_backup", True)
|
|
@@ -301,7 +385,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
301
385
|
b"description": None,
|
|
302
386
|
b"flags": {b"no-writes"},
|
|
303
387
|
}],
|
|
304
|
-
b"library_code": b"#!lua name=mylib
|
|
388
|
+
b"library_code": b"#!lua name=mylib \\n sever.register_function('myfunc', function(keys, args) " \
|
|
389
|
+
b"return args[1] end)"
|
|
305
390
|
}]
|
|
306
391
|
|
|
307
392
|
Since: Valkey 7.0.0.
|
|
@@ -323,7 +408,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
323
408
|
"""
|
|
324
409
|
Deletes all function libraries.
|
|
325
410
|
|
|
326
|
-
See https://valkey.io/commands/function-flush/ for more details.
|
|
411
|
+
See [valkey.io](https://valkey.io/commands/function-flush/) for more details.
|
|
327
412
|
|
|
328
413
|
Args:
|
|
329
414
|
mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -349,7 +434,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
349
434
|
"""
|
|
350
435
|
Deletes a library and all its functions.
|
|
351
436
|
|
|
352
|
-
See https://valkey.io/commands/function-delete/ for more details.
|
|
437
|
+
See [valkey.io](https://valkey.io/commands/function-delete/) for more details.
|
|
353
438
|
|
|
354
439
|
Args:
|
|
355
440
|
library_code (TEncodable): The library name to delete
|
|
@@ -378,7 +463,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
378
463
|
|
|
379
464
|
FUNCTION KILL runs on all nodes of the server, including primary and replicas.
|
|
380
465
|
|
|
381
|
-
See https://valkey.io/commands/function-kill/ for more details.
|
|
466
|
+
See [valkey.io](https://valkey.io/commands/function-kill/) for more details.
|
|
382
467
|
|
|
383
468
|
Returns:
|
|
384
469
|
TOK: A simple `OK`.
|
|
@@ -402,13 +487,15 @@ class StandaloneCommands(CoreCommands):
|
|
|
402
487
|
FUNCTION STATS runs on all nodes of the server, including primary and replicas.
|
|
403
488
|
The response includes a mapping from node address to the command response for that node.
|
|
404
489
|
|
|
405
|
-
See https://valkey.io/commands/function-stats/ for more details
|
|
490
|
+
See [valkey.io](https://valkey.io/commands/function-stats/) for more details
|
|
406
491
|
|
|
407
492
|
Returns:
|
|
408
493
|
TFunctionStatsFullResponse: A Map where the key is the node address and the value is a Map of two keys:
|
|
494
|
+
|
|
409
495
|
- `running_script` with information about the running script.
|
|
410
496
|
- `engines` with information about available engines and their stats.
|
|
411
|
-
|
|
497
|
+
|
|
498
|
+
See example for more details.
|
|
412
499
|
|
|
413
500
|
Examples:
|
|
414
501
|
>>> await client.function_stats()
|
|
@@ -446,7 +533,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
446
533
|
"""
|
|
447
534
|
Returns the serialized payload of all loaded libraries.
|
|
448
535
|
|
|
449
|
-
See https://valkey.io/docs/latest/commands/function-dump/ for more details.
|
|
536
|
+
See [valkey.io](https://valkey.io/docs/latest/commands/function-dump/) for more details.
|
|
450
537
|
|
|
451
538
|
Returns:
|
|
452
539
|
bytes: The serialized payload of all loaded libraries.
|
|
@@ -468,7 +555,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
468
555
|
"""
|
|
469
556
|
Restores libraries from the serialized payload returned by the `function_dump` command.
|
|
470
557
|
|
|
471
|
-
See https://valkey.io/docs/latest/commands/function-restore/ for more details.
|
|
558
|
+
See [valkey.io](https://valkey.io/docs/latest/commands/function-restore/) for more details.
|
|
472
559
|
|
|
473
560
|
Args:
|
|
474
561
|
payload (TEncodable): The serialized data from the `function_dump` command.
|
|
@@ -498,7 +585,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
498
585
|
"""
|
|
499
586
|
Returns the server time.
|
|
500
587
|
|
|
501
|
-
See https://valkey.io/commands/time/ for more details.
|
|
588
|
+
See [valkey.io](https://valkey.io/commands/time/) for more details.
|
|
502
589
|
|
|
503
590
|
Returns:
|
|
504
591
|
List[bytes]: The current server time as a two items `array`:
|
|
@@ -518,7 +605,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
518
605
|
"""
|
|
519
606
|
Returns the Unix time of the last DB save timestamp or startup timestamp if no save was made since then.
|
|
520
607
|
|
|
521
|
-
See https://valkey.io/commands/lastsave for more details.
|
|
608
|
+
See [valkey.io](https://valkey.io/commands/lastsave) for more details.
|
|
522
609
|
|
|
523
610
|
Returns:
|
|
524
611
|
int: The Unix time of the last successful DB save.
|
|
@@ -536,15 +623,17 @@ class StandaloneCommands(CoreCommands):
|
|
|
536
623
|
"""
|
|
537
624
|
Move `key` from the currently selected database to the database specified by `db_index`.
|
|
538
625
|
|
|
539
|
-
See https://valkey.io/commands/move/ for more details.
|
|
626
|
+
See [valkey.io](https://valkey.io/commands/move/) for more details.
|
|
540
627
|
|
|
541
628
|
Args:
|
|
542
629
|
key (TEncodable): The key to move.
|
|
543
630
|
db_index (int): The index of the database to move `key` to.
|
|
544
631
|
|
|
545
632
|
Returns:
|
|
546
|
-
bool: True if `key` was moved
|
|
547
|
-
|
|
633
|
+
bool: `True` if `key` was moved.
|
|
634
|
+
|
|
635
|
+
`False` if the `key` already exists in the destination database
|
|
636
|
+
or does not exist in the source database.
|
|
548
637
|
|
|
549
638
|
Example:
|
|
550
639
|
>>> await client.move("some_key", 1)
|
|
@@ -558,7 +647,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
558
647
|
async def publish(self, message: TEncodable, channel: TEncodable) -> int:
|
|
559
648
|
"""
|
|
560
649
|
Publish a message on pubsub channel.
|
|
561
|
-
|
|
650
|
+
|
|
651
|
+
See [valkey.io](https://valkey.io/commands/publish) for more details.
|
|
562
652
|
|
|
563
653
|
Args:
|
|
564
654
|
message (TEncodable): Message to publish
|
|
@@ -566,7 +656,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
566
656
|
|
|
567
657
|
Returns:
|
|
568
658
|
int: Number of subscriptions in primary node that received the message.
|
|
569
|
-
|
|
659
|
+
|
|
660
|
+
**Note:** this value does not include subscriptions that configured on replicas.
|
|
570
661
|
|
|
571
662
|
Examples:
|
|
572
663
|
>>> await client.publish("Hi all!", "global-channel")
|
|
@@ -580,7 +671,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
580
671
|
"""
|
|
581
672
|
Deletes all the keys of all the existing databases. This command never fails.
|
|
582
673
|
|
|
583
|
-
See https://valkey.io/commands/flushall for more details.
|
|
674
|
+
See [valkey.io](https://valkey.io/commands/flushall) for more details.
|
|
584
675
|
|
|
585
676
|
Args:
|
|
586
677
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -605,7 +696,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
605
696
|
"""
|
|
606
697
|
Deletes all the keys of the currently selected database. This command never fails.
|
|
607
698
|
|
|
608
|
-
See https://valkey.io/commands/flushdb for more details.
|
|
699
|
+
See [valkey.io](https://valkey.io/commands/flushdb) for more details.
|
|
609
700
|
|
|
610
701
|
Args:
|
|
611
702
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -641,7 +732,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
641
732
|
otherwise the current database will be used. When `replace` is True, removes the
|
|
642
733
|
`destination` key first if it already exists, otherwise performs no action.
|
|
643
734
|
|
|
644
|
-
See https://valkey.io/commands/copy for more details.
|
|
735
|
+
See [valkey.io](https://valkey.io/commands/copy) for more details.
|
|
645
736
|
|
|
646
737
|
Args:
|
|
647
738
|
source (TEncodable): The key to the source value.
|
|
@@ -650,7 +741,9 @@ class StandaloneCommands(CoreCommands):
|
|
|
650
741
|
replace (Optional[bool]): If the destination key should be removed before copying the value to it.
|
|
651
742
|
|
|
652
743
|
Returns:
|
|
653
|
-
bool: True if the source was copied.
|
|
744
|
+
bool: True if the source was copied.
|
|
745
|
+
|
|
746
|
+
Otherwise, return False.
|
|
654
747
|
|
|
655
748
|
Examples:
|
|
656
749
|
>>> await client.set("source", "sheep")
|
|
@@ -680,13 +773,14 @@ class StandaloneCommands(CoreCommands):
|
|
|
680
773
|
"""
|
|
681
774
|
Displays a piece of generative computer art and the Valkey version.
|
|
682
775
|
|
|
683
|
-
See https://valkey.io/commands/lolwut for more details.
|
|
776
|
+
See [valkey.io](https://valkey.io/commands/lolwut) for more details.
|
|
684
777
|
|
|
685
778
|
Args:
|
|
686
779
|
version (Optional[int]): Version of computer art to generate.
|
|
687
780
|
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
|
|
688
|
-
|
|
689
|
-
For version `
|
|
781
|
+
|
|
782
|
+
- For version `5`, those are length of the line, number of squares per row, and number of squares per column.
|
|
783
|
+
- For version `6`, those are number of columns and number of lines.
|
|
690
784
|
|
|
691
785
|
Returns:
|
|
692
786
|
bytes: A piece of generative computer art along with the current Valkey version.
|
|
@@ -712,7 +806,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
712
806
|
"""
|
|
713
807
|
Returns a random existing key name from the currently selected database.
|
|
714
808
|
|
|
715
|
-
See https://valkey.io/commands/randomkey for more details.
|
|
809
|
+
See [valkey.io](https://valkey.io/commands/randomkey) for more details.
|
|
716
810
|
|
|
717
811
|
Returns:
|
|
718
812
|
Optional[bytes]: A random existing key name from the currently selected database.
|
|
@@ -736,7 +830,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
736
830
|
and acknowledged by at least `numreplicas` of replicas. If `timeout` is
|
|
737
831
|
reached, the command returns even if the specified number of replicas were not yet reached.
|
|
738
832
|
|
|
739
|
-
See https://valkey.io/commands/wait for more details.
|
|
833
|
+
See [valkey.io](https://valkey.io/commands/wait) for more details.
|
|
740
834
|
|
|
741
835
|
Args:
|
|
742
836
|
numreplicas (int): The number of replicas to reach.
|
|
@@ -748,7 +842,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
748
842
|
Examples:
|
|
749
843
|
>>> await client.set("key", "value");
|
|
750
844
|
>>> await client.wait(1, 1000);
|
|
751
|
-
|
|
845
|
+
# return 1 when a replica is reached or 0 if 1000ms is reached.
|
|
752
846
|
"""
|
|
753
847
|
args: List[TEncodable] = [str(numreplicas), str(timeout)]
|
|
754
848
|
return cast(
|
|
@@ -758,10 +852,10 @@ class StandaloneCommands(CoreCommands):
|
|
|
758
852
|
|
|
759
853
|
async def unwatch(self) -> TOK:
|
|
760
854
|
"""
|
|
761
|
-
Flushes all the previously watched keys for
|
|
855
|
+
Flushes all the previously watched keys for an atomic batch (Transaction). Executing a transaction will
|
|
762
856
|
automatically flush all previously watched keys.
|
|
763
857
|
|
|
764
|
-
See https://valkey.io/commands/unwatch for more details.
|
|
858
|
+
See [valkey.io](https://valkey.io/commands/unwatch) for more details.
|
|
765
859
|
|
|
766
860
|
Returns:
|
|
767
861
|
TOK: A simple "OK" response.
|
|
@@ -794,41 +888,43 @@ class StandaloneCommands(CoreCommands):
|
|
|
794
888
|
in the collection from the start to the end of a full iteration.
|
|
795
889
|
Elements that were not constantly present in the collection during a full iteration, may be returned or not.
|
|
796
890
|
|
|
797
|
-
See https://valkey.io/commands/scan for more details.
|
|
891
|
+
See [valkey.io](https://valkey.io/commands/scan) for more details.
|
|
798
892
|
|
|
799
893
|
Args:
|
|
800
894
|
cursor (TResult): The cursor used for iteration. For the first iteration, the cursor should be set to "0".
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
895
|
+
|
|
896
|
+
- Using a non-zero cursor in the first iteration, or an invalid cursor at any iteration, will lead to
|
|
897
|
+
undefined results.
|
|
898
|
+
- Using the same cursor in multiple iterations will, in case nothing changed between the iterations,
|
|
899
|
+
return the same elements multiple times.
|
|
900
|
+
- If the the db has changed, it may result an undefined behavior.
|
|
901
|
+
|
|
806
902
|
match (Optional[TResult]): A pattern to match keys against.
|
|
807
903
|
count (Optional[int]): The number of keys to return per iteration.
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
The
|
|
904
|
+
|
|
905
|
+
- The number of keys returned per iteration is not guaranteed to be the same as the count argument.
|
|
906
|
+
- The argument is used as a hint for the server to know how many "steps" it can use to retrieve the keys.
|
|
907
|
+
- The default value is 10.
|
|
908
|
+
|
|
811
909
|
type (ObjectType): The type of object to scan for.
|
|
812
910
|
|
|
813
911
|
Returns:
|
|
814
912
|
List[Union[bytes, List[bytes]]]: A List containing the next cursor value and a list of keys,
|
|
815
|
-
|
|
913
|
+
formatted as [cursor, [key1, key2, ...]]
|
|
816
914
|
|
|
817
915
|
Examples:
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
>>> result = await client.scan("0", type=ObjectType.Set)
|
|
831
|
-
print(result) #[b'362', [b'set1', b'set2', b'set3']]
|
|
916
|
+
>>> result = await client.scan(b'0')
|
|
917
|
+
print(result) #[b'17', [b'key1', b'key2', b'key3', b'key4', b'key5', b'set1', b'set2', b'set3']]
|
|
918
|
+
first_cursor_result = result[0]
|
|
919
|
+
result = await client.scan(first_cursor_result)
|
|
920
|
+
print(result) #[b'349', [b'key4', b'key5', b'set1', b'hash1', b'zset1', b'list1', b'list2',
|
|
921
|
+
b'list3', b'zset2', b'zset3', b'zset4', b'zset5', b'zset6']]
|
|
922
|
+
result = await client.scan(result[0])
|
|
923
|
+
print(result) #[b'0', [b'key6', b'key7']]
|
|
924
|
+
>>> result = await client.scan(first_cursor_result, match=b'key*', count=2)
|
|
925
|
+
print(result) #[b'6', [b'key4', b'key5']]
|
|
926
|
+
>>> result = await client.scan("0", type=ObjectType.Set)
|
|
927
|
+
print(result) #[b'362', [b'set1', b'set2', b'set3']]
|
|
832
928
|
"""
|
|
833
929
|
args = [cursor]
|
|
834
930
|
if match:
|
|
@@ -846,7 +942,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
846
942
|
"""
|
|
847
943
|
Check existence of scripts in the script cache by their SHA1 digest.
|
|
848
944
|
|
|
849
|
-
See https://valkey.io/commands/script-exists for more details.
|
|
945
|
+
See [valkey.io](https://valkey.io/commands/script-exists) for more details.
|
|
850
946
|
|
|
851
947
|
Args:
|
|
852
948
|
sha1s (List[TEncodable]): List of SHA1 digests of the scripts to check.
|
|
@@ -866,7 +962,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
866
962
|
"""
|
|
867
963
|
Flush the Lua scripts cache.
|
|
868
964
|
|
|
869
|
-
See https://valkey.io/commands/script-flush for more details.
|
|
965
|
+
See [valkey.io](https://valkey.io/commands/script-flush) for more details.
|
|
870
966
|
|
|
871
967
|
Args:
|
|
872
968
|
mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -893,7 +989,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
893
989
|
"""
|
|
894
990
|
Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
|
|
895
991
|
|
|
896
|
-
See https://valkey.io/commands/script-kill for more details.
|
|
992
|
+
See [valkey.io](https://valkey.io/commands/script-kill) for more details.
|
|
897
993
|
|
|
898
994
|
Returns:
|
|
899
995
|
TOK: A simple `OK` response.
|
|
@@ -917,7 +1013,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
917
1013
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
918
1014
|
After that, it will be invoked using the `EVALSHA` command.
|
|
919
1015
|
|
|
920
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1016
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1017
|
+
for more details.
|
|
921
1018
|
|
|
922
1019
|
Args:
|
|
923
1020
|
script (Script): The Lua script to execute.
|