valkey-glide 1.3.5rc3__cp313-cp313-macosx_11_0_arm64.whl → 2.0.0rc6__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} +1413 -987
- glide/async_commands/bitmap.py +94 -85
- glide/async_commands/cluster_commands.py +308 -123
- glide/async_commands/command_args.py +7 -6
- glide/async_commands/core.py +1304 -714
- 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 +199 -95
- 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 +274 -95
- 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 +41 -8
- {valkey_glide-1.3.5rc3.dist-info → valkey_glide-2.0.0rc6.dist-info}/METADATA +30 -11
- valkey_glide-2.0.0rc6.dist-info/RECORD +37 -0
- valkey_glide-1.3.5rc3.dist-info/RECORD +0 -37
- {valkey_glide-1.3.5rc3.dist-info → valkey_glide-2.0.0rc6.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,21 @@ 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
|
-
|
|
34
|
+
This function should only be used for single-response commands. Commands that don't return complete response and awaits
|
|
35
|
+
(such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the
|
|
36
|
+
client's behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
|
|
35
37
|
|
|
36
|
-
connection.customCommand(["CLIENT", "LIST","TYPE", "PUBSUB"])
|
|
37
38
|
Args:
|
|
38
39
|
command_args (List[TEncodable]): List of the command's arguments, where each argument is either a string or bytes.
|
|
39
40
|
Every part of the command, including the command name and subcommands, should be added as a separate value in args.
|
|
40
41
|
|
|
41
42
|
Returns:
|
|
42
43
|
TResult: The returning value depends on the executed command.
|
|
44
|
+
|
|
45
|
+
Example:
|
|
46
|
+
>>> await client.customCommand(["CLIENT", "LIST", "TYPE", "PUBSUB"])
|
|
47
|
+
# Expected Output: A list of all pub/sub clients
|
|
48
|
+
|
|
43
49
|
"""
|
|
44
50
|
return await self._execute_command(RequestType.CustomCommand, command_args)
|
|
45
51
|
|
|
@@ -49,12 +55,14 @@ class StandaloneCommands(CoreCommands):
|
|
|
49
55
|
) -> bytes:
|
|
50
56
|
"""
|
|
51
57
|
Get information and statistics about the server.
|
|
52
|
-
|
|
58
|
+
|
|
59
|
+
Starting from server version 7, command supports multiple section arguments.
|
|
60
|
+
|
|
61
|
+
See [valkey.io](https://valkey.io/commands/info/) for details.
|
|
53
62
|
|
|
54
63
|
Args:
|
|
55
64
|
sections (Optional[List[InfoSection]]): A list of InfoSection values specifying which sections of
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
information to retrieve. When no parameter is provided, the default option is assumed.
|
|
58
66
|
|
|
59
67
|
Returns:
|
|
60
68
|
bytes: Returns bytes containing the information for the sections requested.
|
|
@@ -66,28 +74,96 @@ class StandaloneCommands(CoreCommands):
|
|
|
66
74
|
|
|
67
75
|
async def exec(
|
|
68
76
|
self,
|
|
69
|
-
|
|
77
|
+
batch: Batch,
|
|
78
|
+
raise_on_error: bool,
|
|
79
|
+
timeout: Optional[int] = None,
|
|
70
80
|
) -> Optional[List[TResult]]:
|
|
71
81
|
"""
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
Executes a batch by processing the queued commands.
|
|
83
|
+
|
|
84
|
+
See [Valkey Transactions (Atomic Batches)](https://valkey.io/docs/topics/transactions/) and
|
|
85
|
+
[Valkey Pipelines (Non-Atomic Batches)](https://valkey.io/docs/topics/pipelining/) for details.
|
|
86
|
+
|
|
87
|
+
Notes:
|
|
88
|
+
- Atomic Batches - Transactions: If the transaction fails due to a ``WATCH`` command,
|
|
89
|
+
``exec`` will return ``None``.
|
|
74
90
|
|
|
75
91
|
Args:
|
|
76
|
-
|
|
92
|
+
batch (Batch): A ``Batch`` containing the commands to execute.
|
|
93
|
+
raise_on_error (bool): Determines how errors are handled within the batch response.
|
|
94
|
+
When set to ``True``, the first encountered error in the batch will be raised as a
|
|
95
|
+
``RequestError`` exception after all retries and reconnections have been executed.
|
|
96
|
+
When set to ``False``, errors will be included as part of the batch response array, allowing
|
|
97
|
+
the caller to process both successful and failed commands together. In this case, error details
|
|
98
|
+
will be provided as instances of ``RequestError``.
|
|
99
|
+
timeout (Optional[int]): The duration in milliseconds that the client should wait for the batch request
|
|
100
|
+
to complete. This duration encompasses sending the request, awaiting a response from the server, and any
|
|
101
|
+
required reconnections or retries. If the specified timeout is exceeded for the request,
|
|
102
|
+
a timeout error will be raised. If not explicitly set, the client's default request timeout will be used.
|
|
77
103
|
|
|
78
104
|
Returns:
|
|
79
|
-
Optional[List[TResult]]:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
105
|
+
Optional[List[TResult]]: An array of results, where each entry corresponds to a command's execution result.
|
|
106
|
+
If the batch fails due to a ``WATCH`` command, ``exec`` will return ``None``.
|
|
107
|
+
|
|
108
|
+
Example (Atomic Batch - Transaction):
|
|
109
|
+
>>> transaction = Batch(is_atomic=True) # Atomic (Transaction)
|
|
110
|
+
>>> transaction.set("key", "1")
|
|
111
|
+
>>> transaction.incr("key")
|
|
112
|
+
>>> transaction.get("key")
|
|
113
|
+
>>> result = await client.exec(transaction, raise_on_error=True)
|
|
114
|
+
>>> print(f"Transaction Batch Result: {result}")
|
|
115
|
+
# Expected Output: Transaction Batch Result: [OK, 2, b'2']
|
|
116
|
+
|
|
117
|
+
Example (Non-Atomic Batch - Pipeline):
|
|
118
|
+
>>> pipeline = Batch(is_atomic=False) # Non-Atomic (Pipeline)
|
|
119
|
+
>>> pipeline.set("key1", "value1")
|
|
120
|
+
>>> pipeline.set("key2", "value2")
|
|
121
|
+
>>> pipeline.get("key1")
|
|
122
|
+
>>> pipeline.get("key2")
|
|
123
|
+
>>> result = await client.exec(pipeline, raise_on_error=True)
|
|
124
|
+
>>> print(f"Pipeline Batch Result: {result}")
|
|
125
|
+
# Expected Output: Pipeline Batch Result: [OK, OK, b'value1', b'value2']
|
|
126
|
+
|
|
127
|
+
Example (Atomic Batch - Transaction with options):
|
|
128
|
+
>>> transaction = Batch(is_atomic=True)
|
|
129
|
+
>>> transaction.set("key", "1")
|
|
130
|
+
>>> transaction.incr("key")
|
|
131
|
+
>>> transaction.custom_command(["get", "key"])
|
|
132
|
+
>>> result = await client.exec(
|
|
133
|
+
... transaction,
|
|
134
|
+
... raise_on_error=False, # Do not raise an error on failure
|
|
135
|
+
... timeout=1000 # Set a timeout of 1000 milliseconds
|
|
136
|
+
... )
|
|
137
|
+
>>> print(f"Transaction Result: {result}")
|
|
138
|
+
# Expected Output: Transaction Result: [OK, 2, b'2']
|
|
139
|
+
|
|
140
|
+
Example (Non-Atomic Batch - Pipeline with options):
|
|
141
|
+
>>> pipeline = Batch(is_atomic=False)
|
|
142
|
+
>>> pipeline.custom_command(["set", "key1", "value1"])
|
|
143
|
+
>>> pipeline.custom_command(["set", "key2", "value2"])
|
|
144
|
+
>>> pipeline.custom_command(["get", "key1"])
|
|
145
|
+
>>> pipeline.custom_command(["get", "key2"])
|
|
146
|
+
>>> result = await client.exec(
|
|
147
|
+
... pipeline,
|
|
148
|
+
... raise_on_error=False, # Do not raise an error on failure
|
|
149
|
+
... timeout=1000 # Set a timeout of 1000 milliseconds
|
|
150
|
+
... )
|
|
151
|
+
>>> print(f"Pipeline Result: {result}")
|
|
152
|
+
# Expected Output: Pipeline Result: [OK, OK, b'value1', b'value2']
|
|
153
|
+
"""
|
|
154
|
+
commands = batch.commands[:]
|
|
155
|
+
return await self._execute_batch(
|
|
156
|
+
commands,
|
|
157
|
+
is_atomic=batch.is_atomic,
|
|
158
|
+
raise_on_error=raise_on_error,
|
|
159
|
+
timeout=timeout,
|
|
160
|
+
)
|
|
86
161
|
|
|
87
162
|
async def select(self, index: int) -> TOK:
|
|
88
163
|
"""
|
|
89
164
|
Change the currently selected database.
|
|
90
|
-
|
|
165
|
+
|
|
166
|
+
See [valkey.io](https://valkey.io/commands/select/) for details.
|
|
91
167
|
|
|
92
168
|
Args:
|
|
93
169
|
index (int): The index of the database to select.
|
|
@@ -100,7 +176,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
100
176
|
async def config_resetstat(self) -> TOK:
|
|
101
177
|
"""
|
|
102
178
|
Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
|
|
103
|
-
|
|
179
|
+
|
|
180
|
+
See [valkey.io](https://valkey.io/commands/config-resetstat/) for details.
|
|
104
181
|
|
|
105
182
|
Returns:
|
|
106
183
|
OK: Returns "OK" to confirm that the statistics were successfully reset.
|
|
@@ -110,10 +187,13 @@ class StandaloneCommands(CoreCommands):
|
|
|
110
187
|
async def config_rewrite(self) -> TOK:
|
|
111
188
|
"""
|
|
112
189
|
Rewrite the configuration file with the current configuration.
|
|
113
|
-
|
|
190
|
+
|
|
191
|
+
See [valkey.io](https://valkey.io/commands/config-rewrite/) for details.
|
|
114
192
|
|
|
115
193
|
Returns:
|
|
116
|
-
OK: OK is returned when the configuration was rewritten properly.
|
|
194
|
+
OK: OK is returned when the configuration was rewritten properly.
|
|
195
|
+
|
|
196
|
+
Otherwise, an error is raised.
|
|
117
197
|
"""
|
|
118
198
|
return cast(TOK, await self._execute_command(RequestType.ConfigRewrite, []))
|
|
119
199
|
|
|
@@ -122,7 +202,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
122
202
|
) -> int:
|
|
123
203
|
"""
|
|
124
204
|
Returns the current connection id.
|
|
125
|
-
|
|
205
|
+
|
|
206
|
+
See [valkey.io](https://valkey.io/commands/client-id/) for more information.
|
|
126
207
|
|
|
127
208
|
Returns:
|
|
128
209
|
int: the id of the client.
|
|
@@ -132,14 +213,17 @@ class StandaloneCommands(CoreCommands):
|
|
|
132
213
|
async def ping(self, message: Optional[TEncodable] = None) -> bytes:
|
|
133
214
|
"""
|
|
134
215
|
Ping the server.
|
|
135
|
-
|
|
216
|
+
|
|
217
|
+
See [valkey.io](https://valkey.io/commands/ping/) for more details.
|
|
136
218
|
|
|
137
219
|
Args:
|
|
138
|
-
|
|
139
|
-
|
|
220
|
+
message (Optional[TEncodable]): An optional message to include in the PING command. If not provided,
|
|
221
|
+
the server will respond with b"PONG". If provided, the server will respond with a copy of the message.
|
|
140
222
|
|
|
141
223
|
Returns:
|
|
142
|
-
|
|
224
|
+
bytes: b"PONG" if `message` is not provided.
|
|
225
|
+
|
|
226
|
+
Otherwise return a copy of `message`.
|
|
143
227
|
|
|
144
228
|
Examples:
|
|
145
229
|
>>> await client.ping()
|
|
@@ -153,8 +237,9 @@ class StandaloneCommands(CoreCommands):
|
|
|
153
237
|
async def config_get(self, parameters: List[TEncodable]) -> Dict[bytes, bytes]:
|
|
154
238
|
"""
|
|
155
239
|
Get the values of configuration parameters.
|
|
156
|
-
Starting from server version 7, command supports multiple parameters
|
|
157
|
-
|
|
240
|
+
Starting from server version 7, command supports multiple parameters
|
|
241
|
+
|
|
242
|
+
See [valkey.io](https://valkey.io/commands/config-get/) for details.
|
|
158
243
|
|
|
159
244
|
Args:
|
|
160
245
|
parameters (List[TEncodable]): A list of configuration parameter names to retrieve values for.
|
|
@@ -177,14 +262,17 @@ class StandaloneCommands(CoreCommands):
|
|
|
177
262
|
"""
|
|
178
263
|
Set configuration parameters to the specified values.
|
|
179
264
|
Starting from server version 7, command supports multiple parameters.
|
|
180
|
-
|
|
265
|
+
|
|
266
|
+
See [valkey.io](https://valkey.io/commands/config-set/) for details.
|
|
181
267
|
|
|
182
268
|
Args:
|
|
183
269
|
parameters_map (Mapping[TEncodable, TEncodable]): A map consisting of configuration
|
|
184
|
-
|
|
270
|
+
parameters and their respective values to set.
|
|
185
271
|
|
|
186
272
|
Returns:
|
|
187
|
-
OK: Returns OK if all configurations have been successfully set.
|
|
273
|
+
OK: Returns OK if all configurations have been successfully set.
|
|
274
|
+
|
|
275
|
+
Otherwise, raises an error.
|
|
188
276
|
|
|
189
277
|
Examples:
|
|
190
278
|
>>> config_set({"timeout": "1000", "maxmemory": "1GB"})
|
|
@@ -198,11 +286,13 @@ class StandaloneCommands(CoreCommands):
|
|
|
198
286
|
async def client_getname(self) -> Optional[bytes]:
|
|
199
287
|
"""
|
|
200
288
|
Get the name of the primary's connection.
|
|
201
|
-
|
|
289
|
+
|
|
290
|
+
See [valkey.io](https://valkey.io/commands/client-getname/) for more details.
|
|
202
291
|
|
|
203
292
|
Returns:
|
|
204
|
-
Optional[bytes]: Returns the name of the client connection as a byte string if a name is set
|
|
205
|
-
|
|
293
|
+
Optional[bytes]: Returns the name of the client connection as a byte string if a name is set.
|
|
294
|
+
|
|
295
|
+
`None` if no name is assigned.
|
|
206
296
|
|
|
207
297
|
Examples:
|
|
208
298
|
>>> await client.client_getname()
|
|
@@ -215,7 +305,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
215
305
|
async def dbsize(self) -> int:
|
|
216
306
|
"""
|
|
217
307
|
Returns the number of keys in the currently selected database.
|
|
218
|
-
|
|
308
|
+
|
|
309
|
+
See [valkey.io](https://valkey.io/commands/dbsize) for more details.
|
|
219
310
|
|
|
220
311
|
Returns:
|
|
221
312
|
int: The number of keys in the currently selected database.
|
|
@@ -230,7 +321,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
230
321
|
"""
|
|
231
322
|
Echoes the provided `message` back.
|
|
232
323
|
|
|
233
|
-
See https://valkey.io/commands/echo for more details.
|
|
324
|
+
See [valkey.io](https://valkey.io/commands/echo) for more details.
|
|
234
325
|
|
|
235
326
|
Args:
|
|
236
327
|
message (TEncodable): The message to be echoed back.
|
|
@@ -250,7 +341,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
250
341
|
"""
|
|
251
342
|
Loads a library to Valkey.
|
|
252
343
|
|
|
253
|
-
See https://valkey.io/commands/function-load/ for more details.
|
|
344
|
+
See [valkey.io](https://valkey.io/commands/function-load/) for more details.
|
|
254
345
|
|
|
255
346
|
Args:
|
|
256
347
|
library_code (TEncodable): The source code that implements the library.
|
|
@@ -261,7 +352,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
261
352
|
bytes: The library name that was loaded.
|
|
262
353
|
|
|
263
354
|
Examples:
|
|
264
|
-
>>> code = "#!lua name=mylib
|
|
355
|
+
>>> code = "#!lua name=mylib \\n redis.register_function('myfunc', function(keys, args) return args[1] end)"
|
|
265
356
|
>>> await client.function_load(code, True)
|
|
266
357
|
b"mylib"
|
|
267
358
|
|
|
@@ -281,7 +372,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
281
372
|
"""
|
|
282
373
|
Returns information about the functions and libraries.
|
|
283
374
|
|
|
284
|
-
See https://valkey.io/commands/function-list/ for more details.
|
|
375
|
+
See [valkey.io](https://valkey.io/commands/function-list/) for more details.
|
|
285
376
|
|
|
286
377
|
Args:
|
|
287
378
|
library_name_pattern (Optional[TEncodable]): A wildcard pattern for matching library names.
|
|
@@ -289,7 +380,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
289
380
|
|
|
290
381
|
Returns:
|
|
291
382
|
TFunctionListResponse: Info about all or
|
|
292
|
-
|
|
383
|
+
selected libraries and their functions.
|
|
293
384
|
|
|
294
385
|
Examples:
|
|
295
386
|
>>> response = await client.function_list("myLib?_backup", True)
|
|
@@ -301,7 +392,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
301
392
|
b"description": None,
|
|
302
393
|
b"flags": {b"no-writes"},
|
|
303
394
|
}],
|
|
304
|
-
b"library_code": b"#!lua name=mylib
|
|
395
|
+
b"library_code": b"#!lua name=mylib \\n sever.register_function('myfunc', function(keys, args) " \
|
|
396
|
+
b"return args[1] end)"
|
|
305
397
|
}]
|
|
306
398
|
|
|
307
399
|
Since: Valkey 7.0.0.
|
|
@@ -323,7 +415,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
323
415
|
"""
|
|
324
416
|
Deletes all function libraries.
|
|
325
417
|
|
|
326
|
-
See https://valkey.io/commands/function-flush/ for more details.
|
|
418
|
+
See [valkey.io](https://valkey.io/commands/function-flush/) for more details.
|
|
327
419
|
|
|
328
420
|
Args:
|
|
329
421
|
mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -349,7 +441,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
349
441
|
"""
|
|
350
442
|
Deletes a library and all its functions.
|
|
351
443
|
|
|
352
|
-
See https://valkey.io/commands/function-delete/ for more details.
|
|
444
|
+
See [valkey.io](https://valkey.io/commands/function-delete/) for more details.
|
|
353
445
|
|
|
354
446
|
Args:
|
|
355
447
|
library_code (TEncodable): The library name to delete
|
|
@@ -378,7 +470,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
378
470
|
|
|
379
471
|
FUNCTION KILL runs on all nodes of the server, including primary and replicas.
|
|
380
472
|
|
|
381
|
-
See https://valkey.io/commands/function-kill/ for more details.
|
|
473
|
+
See [valkey.io](https://valkey.io/commands/function-kill/) for more details.
|
|
382
474
|
|
|
383
475
|
Returns:
|
|
384
476
|
TOK: A simple `OK`.
|
|
@@ -402,13 +494,15 @@ class StandaloneCommands(CoreCommands):
|
|
|
402
494
|
FUNCTION STATS runs on all nodes of the server, including primary and replicas.
|
|
403
495
|
The response includes a mapping from node address to the command response for that node.
|
|
404
496
|
|
|
405
|
-
See https://valkey.io/commands/function-stats/ for more details
|
|
497
|
+
See [valkey.io](https://valkey.io/commands/function-stats/) for more details
|
|
406
498
|
|
|
407
499
|
Returns:
|
|
408
500
|
TFunctionStatsFullResponse: A Map where the key is the node address and the value is a Map of two keys:
|
|
501
|
+
|
|
409
502
|
- `running_script` with information about the running script.
|
|
410
503
|
- `engines` with information about available engines and their stats.
|
|
411
|
-
|
|
504
|
+
|
|
505
|
+
See example for more details.
|
|
412
506
|
|
|
413
507
|
Examples:
|
|
414
508
|
>>> await client.function_stats()
|
|
@@ -446,7 +540,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
446
540
|
"""
|
|
447
541
|
Returns the serialized payload of all loaded libraries.
|
|
448
542
|
|
|
449
|
-
See https://valkey.io/docs/latest/commands/function-dump/ for more details.
|
|
543
|
+
See [valkey.io](https://valkey.io/docs/latest/commands/function-dump/) for more details.
|
|
450
544
|
|
|
451
545
|
Returns:
|
|
452
546
|
bytes: The serialized payload of all loaded libraries.
|
|
@@ -468,7 +562,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
468
562
|
"""
|
|
469
563
|
Restores libraries from the serialized payload returned by the `function_dump` command.
|
|
470
564
|
|
|
471
|
-
See https://valkey.io/docs/latest/commands/function-restore/ for more details.
|
|
565
|
+
See [valkey.io](https://valkey.io/docs/latest/commands/function-restore/) for more details.
|
|
472
566
|
|
|
473
567
|
Args:
|
|
474
568
|
payload (TEncodable): The serialized data from the `function_dump` command.
|
|
@@ -498,7 +592,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
498
592
|
"""
|
|
499
593
|
Returns the server time.
|
|
500
594
|
|
|
501
|
-
See https://valkey.io/commands/time/ for more details.
|
|
595
|
+
See [valkey.io](https://valkey.io/commands/time/) for more details.
|
|
502
596
|
|
|
503
597
|
Returns:
|
|
504
598
|
List[bytes]: The current server time as a two items `array`:
|
|
@@ -518,7 +612,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
518
612
|
"""
|
|
519
613
|
Returns the Unix time of the last DB save timestamp or startup timestamp if no save was made since then.
|
|
520
614
|
|
|
521
|
-
See https://valkey.io/commands/lastsave for more details.
|
|
615
|
+
See [valkey.io](https://valkey.io/commands/lastsave) for more details.
|
|
522
616
|
|
|
523
617
|
Returns:
|
|
524
618
|
int: The Unix time of the last successful DB save.
|
|
@@ -536,15 +630,17 @@ class StandaloneCommands(CoreCommands):
|
|
|
536
630
|
"""
|
|
537
631
|
Move `key` from the currently selected database to the database specified by `db_index`.
|
|
538
632
|
|
|
539
|
-
See https://valkey.io/commands/move/ for more details.
|
|
633
|
+
See [valkey.io](https://valkey.io/commands/move/) for more details.
|
|
540
634
|
|
|
541
635
|
Args:
|
|
542
636
|
key (TEncodable): The key to move.
|
|
543
637
|
db_index (int): The index of the database to move `key` to.
|
|
544
638
|
|
|
545
639
|
Returns:
|
|
546
|
-
bool: True if `key` was moved
|
|
547
|
-
|
|
640
|
+
bool: `True` if `key` was moved.
|
|
641
|
+
|
|
642
|
+
`False` if the `key` already exists in the destination database
|
|
643
|
+
or does not exist in the source database.
|
|
548
644
|
|
|
549
645
|
Example:
|
|
550
646
|
>>> await client.move("some_key", 1)
|
|
@@ -558,7 +654,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
558
654
|
async def publish(self, message: TEncodable, channel: TEncodable) -> int:
|
|
559
655
|
"""
|
|
560
656
|
Publish a message on pubsub channel.
|
|
561
|
-
|
|
657
|
+
|
|
658
|
+
See [valkey.io](https://valkey.io/commands/publish) for more details.
|
|
562
659
|
|
|
563
660
|
Args:
|
|
564
661
|
message (TEncodable): Message to publish
|
|
@@ -566,7 +663,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
566
663
|
|
|
567
664
|
Returns:
|
|
568
665
|
int: Number of subscriptions in primary node that received the message.
|
|
569
|
-
|
|
666
|
+
|
|
667
|
+
**Note:** this value does not include subscriptions that configured on replicas.
|
|
570
668
|
|
|
571
669
|
Examples:
|
|
572
670
|
>>> await client.publish("Hi all!", "global-channel")
|
|
@@ -580,7 +678,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
580
678
|
"""
|
|
581
679
|
Deletes all the keys of all the existing databases. This command never fails.
|
|
582
680
|
|
|
583
|
-
See https://valkey.io/commands/flushall for more details.
|
|
681
|
+
See [valkey.io](https://valkey.io/commands/flushall) for more details.
|
|
584
682
|
|
|
585
683
|
Args:
|
|
586
684
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -605,7 +703,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
605
703
|
"""
|
|
606
704
|
Deletes all the keys of the currently selected database. This command never fails.
|
|
607
705
|
|
|
608
|
-
See https://valkey.io/commands/flushdb for more details.
|
|
706
|
+
See [valkey.io](https://valkey.io/commands/flushdb) for more details.
|
|
609
707
|
|
|
610
708
|
Args:
|
|
611
709
|
flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -641,7 +739,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
641
739
|
otherwise the current database will be used. When `replace` is True, removes the
|
|
642
740
|
`destination` key first if it already exists, otherwise performs no action.
|
|
643
741
|
|
|
644
|
-
See https://valkey.io/commands/copy for more details.
|
|
742
|
+
See [valkey.io](https://valkey.io/commands/copy) for more details.
|
|
645
743
|
|
|
646
744
|
Args:
|
|
647
745
|
source (TEncodable): The key to the source value.
|
|
@@ -650,7 +748,9 @@ class StandaloneCommands(CoreCommands):
|
|
|
650
748
|
replace (Optional[bool]): If the destination key should be removed before copying the value to it.
|
|
651
749
|
|
|
652
750
|
Returns:
|
|
653
|
-
bool: True if the source was copied.
|
|
751
|
+
bool: True if the source was copied.
|
|
752
|
+
|
|
753
|
+
Otherwise, return False.
|
|
654
754
|
|
|
655
755
|
Examples:
|
|
656
756
|
>>> await client.set("source", "sheep")
|
|
@@ -680,13 +780,14 @@ class StandaloneCommands(CoreCommands):
|
|
|
680
780
|
"""
|
|
681
781
|
Displays a piece of generative computer art and the Valkey version.
|
|
682
782
|
|
|
683
|
-
See https://valkey.io/commands/lolwut for more details.
|
|
783
|
+
See [valkey.io](https://valkey.io/commands/lolwut) for more details.
|
|
684
784
|
|
|
685
785
|
Args:
|
|
686
786
|
version (Optional[int]): Version of computer art to generate.
|
|
687
787
|
parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
|
|
688
|
-
|
|
689
|
-
For version `
|
|
788
|
+
|
|
789
|
+
- For version `5`, those are length of the line, number of squares per row, and number of squares per column.
|
|
790
|
+
- For version `6`, those are number of columns and number of lines.
|
|
690
791
|
|
|
691
792
|
Returns:
|
|
692
793
|
bytes: A piece of generative computer art along with the current Valkey version.
|
|
@@ -712,7 +813,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
712
813
|
"""
|
|
713
814
|
Returns a random existing key name from the currently selected database.
|
|
714
815
|
|
|
715
|
-
See https://valkey.io/commands/randomkey for more details.
|
|
816
|
+
See [valkey.io](https://valkey.io/commands/randomkey) for more details.
|
|
716
817
|
|
|
717
818
|
Returns:
|
|
718
819
|
Optional[bytes]: A random existing key name from the currently selected database.
|
|
@@ -736,7 +837,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
736
837
|
and acknowledged by at least `numreplicas` of replicas. If `timeout` is
|
|
737
838
|
reached, the command returns even if the specified number of replicas were not yet reached.
|
|
738
839
|
|
|
739
|
-
See https://valkey.io/commands/wait for more details.
|
|
840
|
+
See [valkey.io](https://valkey.io/commands/wait) for more details.
|
|
740
841
|
|
|
741
842
|
Args:
|
|
742
843
|
numreplicas (int): The number of replicas to reach.
|
|
@@ -748,7 +849,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
748
849
|
Examples:
|
|
749
850
|
>>> await client.set("key", "value");
|
|
750
851
|
>>> await client.wait(1, 1000);
|
|
751
|
-
|
|
852
|
+
# return 1 when a replica is reached or 0 if 1000ms is reached.
|
|
752
853
|
"""
|
|
753
854
|
args: List[TEncodable] = [str(numreplicas), str(timeout)]
|
|
754
855
|
return cast(
|
|
@@ -758,10 +859,10 @@ class StandaloneCommands(CoreCommands):
|
|
|
758
859
|
|
|
759
860
|
async def unwatch(self) -> TOK:
|
|
760
861
|
"""
|
|
761
|
-
Flushes all the previously watched keys for
|
|
862
|
+
Flushes all the previously watched keys for an atomic batch (Transaction). Executing a transaction will
|
|
762
863
|
automatically flush all previously watched keys.
|
|
763
864
|
|
|
764
|
-
See https://valkey.io/commands/unwatch for more details.
|
|
865
|
+
See [valkey.io](https://valkey.io/commands/unwatch) for more details.
|
|
765
866
|
|
|
766
867
|
Returns:
|
|
767
868
|
TOK: A simple "OK" response.
|
|
@@ -794,41 +895,43 @@ class StandaloneCommands(CoreCommands):
|
|
|
794
895
|
in the collection from the start to the end of a full iteration.
|
|
795
896
|
Elements that were not constantly present in the collection during a full iteration, may be returned or not.
|
|
796
897
|
|
|
797
|
-
See https://valkey.io/commands/scan for more details.
|
|
898
|
+
See [valkey.io](https://valkey.io/commands/scan) for more details.
|
|
798
899
|
|
|
799
900
|
Args:
|
|
800
901
|
cursor (TResult): The cursor used for iteration. For the first iteration, the cursor should be set to "0".
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
902
|
+
|
|
903
|
+
- Using a non-zero cursor in the first iteration, or an invalid cursor at any iteration, will lead to
|
|
904
|
+
undefined results.
|
|
905
|
+
- Using the same cursor in multiple iterations will, in case nothing changed between the iterations,
|
|
906
|
+
return the same elements multiple times.
|
|
907
|
+
- If the the db has changed, it may result an undefined behavior.
|
|
908
|
+
|
|
806
909
|
match (Optional[TResult]): A pattern to match keys against.
|
|
807
910
|
count (Optional[int]): The number of keys to return per iteration.
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
The
|
|
911
|
+
|
|
912
|
+
- The number of keys returned per iteration is not guaranteed to be the same as the count argument.
|
|
913
|
+
- The argument is used as a hint for the server to know how many "steps" it can use to retrieve the keys.
|
|
914
|
+
- The default value is 10.
|
|
915
|
+
|
|
811
916
|
type (ObjectType): The type of object to scan for.
|
|
812
917
|
|
|
813
918
|
Returns:
|
|
814
919
|
List[Union[bytes, List[bytes]]]: A List containing the next cursor value and a list of keys,
|
|
815
|
-
|
|
920
|
+
formatted as [cursor, [key1, key2, ...]]
|
|
816
921
|
|
|
817
922
|
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']]
|
|
923
|
+
>>> result = await client.scan(b'0')
|
|
924
|
+
print(result) #[b'17', [b'key1', b'key2', b'key3', b'key4', b'key5', b'set1', b'set2', b'set3']]
|
|
925
|
+
first_cursor_result = result[0]
|
|
926
|
+
result = await client.scan(first_cursor_result)
|
|
927
|
+
print(result) #[b'349', [b'key4', b'key5', b'set1', b'hash1', b'zset1', b'list1', b'list2',
|
|
928
|
+
b'list3', b'zset2', b'zset3', b'zset4', b'zset5', b'zset6']]
|
|
929
|
+
result = await client.scan(result[0])
|
|
930
|
+
print(result) #[b'0', [b'key6', b'key7']]
|
|
931
|
+
>>> result = await client.scan(first_cursor_result, match=b'key*', count=2)
|
|
932
|
+
print(result) #[b'6', [b'key4', b'key5']]
|
|
933
|
+
>>> result = await client.scan("0", type=ObjectType.Set)
|
|
934
|
+
print(result) #[b'362', [b'set1', b'set2', b'set3']]
|
|
832
935
|
"""
|
|
833
936
|
args = [cursor]
|
|
834
937
|
if match:
|
|
@@ -846,7 +949,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
846
949
|
"""
|
|
847
950
|
Check existence of scripts in the script cache by their SHA1 digest.
|
|
848
951
|
|
|
849
|
-
See https://valkey.io/commands/script-exists for more details.
|
|
952
|
+
See [valkey.io](https://valkey.io/commands/script-exists) for more details.
|
|
850
953
|
|
|
851
954
|
Args:
|
|
852
955
|
sha1s (List[TEncodable]): List of SHA1 digests of the scripts to check.
|
|
@@ -866,7 +969,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
866
969
|
"""
|
|
867
970
|
Flush the Lua scripts cache.
|
|
868
971
|
|
|
869
|
-
See https://valkey.io/commands/script-flush for more details.
|
|
972
|
+
See [valkey.io](https://valkey.io/commands/script-flush) for more details.
|
|
870
973
|
|
|
871
974
|
Args:
|
|
872
975
|
mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
|
|
@@ -893,7 +996,7 @@ class StandaloneCommands(CoreCommands):
|
|
|
893
996
|
"""
|
|
894
997
|
Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
|
|
895
998
|
|
|
896
|
-
See https://valkey.io/commands/script-kill for more details.
|
|
999
|
+
See [valkey.io](https://valkey.io/commands/script-kill) for more details.
|
|
897
1000
|
|
|
898
1001
|
Returns:
|
|
899
1002
|
TOK: A simple `OK` response.
|
|
@@ -917,7 +1020,8 @@ class StandaloneCommands(CoreCommands):
|
|
|
917
1020
|
If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
|
|
918
1021
|
After that, it will be invoked using the `EVALSHA` command.
|
|
919
1022
|
|
|
920
|
-
See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/
|
|
1023
|
+
See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
|
|
1024
|
+
for more details.
|
|
921
1025
|
|
|
922
1026
|
Args:
|
|
923
1027
|
script (Script): The Lua script to execute.
|