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