valkey-glide 1.3.5__cp39-cp39-macosx_11_0_arm64.whl → 2.2.2__cp39-cp39-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. glide/__init__.py +165 -107
  2. glide/async_commands/cluster_commands.py +318 -136
  3. glide/async_commands/core.py +1770 -992
  4. glide/async_commands/{server_modules/ft.py → ft.py} +91 -21
  5. glide/async_commands/{server_modules/glide_json.py → glide_json.py} +148 -134
  6. glide/async_commands/standalone_commands.py +203 -137
  7. glide/glide.cpython-39-darwin.so +0 -0
  8. glide/glide.pyi +26 -1
  9. glide/glide_client.py +352 -135
  10. glide/logger.py +34 -22
  11. glide/opentelemetry.py +185 -0
  12. glide_shared/__init__.py +330 -0
  13. glide_shared/commands/__init__.py +0 -0
  14. glide/async_commands/transaction.py → glide_shared/commands/batch.py +1839 -1017
  15. glide_shared/commands/batch_options.py +261 -0
  16. {glide/async_commands → glide_shared/commands}/bitmap.py +94 -85
  17. {glide/async_commands → glide_shared/commands}/command_args.py +7 -6
  18. glide_shared/commands/core_options.py +407 -0
  19. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +18 -11
  20. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +27 -13
  21. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +16 -11
  22. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +16 -8
  23. {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +160 -130
  24. glide_shared/commands/server_modules/json_options.py +93 -0
  25. {glide/async_commands → glide_shared/commands}/sorted_set.py +41 -31
  26. {glide/async_commands → glide_shared/commands}/stream.py +95 -88
  27. glide_shared/config.py +975 -0
  28. {glide → glide_shared}/constants.py +11 -7
  29. {glide → glide_shared}/exceptions.py +27 -1
  30. glide_shared/protobuf/command_request_pb2.py +56 -0
  31. glide_shared/protobuf/connection_request_pb2.py +56 -0
  32. {glide → glide_shared}/protobuf/response_pb2.py +6 -6
  33. {glide → glide_shared}/protobuf_codec.py +7 -6
  34. glide_shared/routes.py +161 -0
  35. valkey_glide-2.2.2.dist-info/METADATA +211 -0
  36. valkey_glide-2.2.2.dist-info/RECORD +40 -0
  37. glide/config.py +0 -590
  38. glide/protobuf/command_request_pb2.py +0 -54
  39. glide/protobuf/command_request_pb2.pyi +0 -1164
  40. glide/protobuf/connection_request_pb2.py +0 -52
  41. glide/protobuf/connection_request_pb2.pyi +0 -292
  42. glide/protobuf/response_pb2.pyi +0 -101
  43. glide/routes.py +0 -114
  44. valkey_glide-1.3.5.dist-info/METADATA +0 -125
  45. valkey_glide-1.3.5.dist-info/RECORD +0 -37
  46. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
  47. {valkey_glide-1.3.5.dist-info → valkey_glide-2.2.2.dist-info}/WHEEL +0 -0
@@ -4,24 +4,25 @@ from __future__ import annotations
4
4
 
5
5
  from typing import Dict, List, Mapping, Optional, Union, cast
6
6
 
7
- from glide.async_commands.command_args import ObjectType
8
- from glide.async_commands.core import (
9
- CoreCommands,
7
+ from glide.glide import Script
8
+ from glide_shared.commands.batch import Batch
9
+ from glide_shared.commands.batch_options import BatchOptions
10
+ from glide_shared.commands.command_args import ObjectType
11
+ from glide_shared.commands.core_options import (
10
12
  FlushMode,
11
13
  FunctionRestorePolicy,
12
14
  InfoSection,
13
15
  )
14
- from glide.async_commands.transaction import Transaction
15
- from glide.constants import (
16
+ from glide_shared.constants import (
16
17
  TOK,
17
18
  TEncodable,
18
19
  TFunctionListResponse,
19
20
  TFunctionStatsFullResponse,
20
21
  TResult,
21
22
  )
22
- from glide.protobuf.command_request_pb2 import RequestType
23
+ from glide_shared.protobuf.command_request_pb2 import RequestType
23
24
 
24
- from ..glide import Script
25
+ from .core import CoreCommands
25
26
 
26
27
 
27
28
  class StandaloneCommands(CoreCommands):
@@ -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
- @example - Return a list of all pub/sub clients:
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
- See https://valkey.io/commands/info/ for details.
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
- information to retrieve. When no parameter is provided, the default option is assumed.
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,41 +75,98 @@ class StandaloneCommands(CoreCommands):
66
75
 
67
76
  async def exec(
68
77
  self,
69
- transaction: Transaction,
78
+ batch: Batch,
79
+ raise_on_error: bool,
80
+ options: Optional[BatchOptions] = None,
70
81
  ) -> Optional[List[TResult]]:
71
82
  """
72
- Execute a transaction by processing the queued commands.
73
- See https://valkey.io/docs/topics/transactions/ for details on Transactions.
74
-
75
- Args:
76
- transaction (Transaction): A `Transaction` object containing a list of commands to be executed.
83
+ Executes a batch by processing the queued commands.
77
84
 
78
- Returns:
79
- Optional[List[TResult]]: A list of results corresponding to the execution of each command
80
- in the transaction. If a command returns a value, it will be included in the list. If a command
81
- doesn't return a value, the list entry will be `None`.
82
- If the transaction failed due to a WATCH command, `exec` will return `None`.
83
- """
84
- commands = transaction.commands[:]
85
- return await self._execute_transaction(commands)
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.
86
87
 
87
- async def select(self, index: int) -> TOK:
88
- """
89
- Change the currently selected database.
90
- See https://valkey.io/commands/select/ for details.
88
+ Notes:
89
+ - Atomic Batches - Transactions: If the transaction fails due to a ``WATCH`` command,
90
+ ``exec`` will return ``None``.
91
91
 
92
92
  Args:
93
- index (int): The index of the database to select.
94
-
95
- Returns:
96
- A simple OK response.
97
- """
98
- return cast(TOK, await self._execute_command(RequestType.Select, [str(index)]))
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.
101
+
102
+ Returns:
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
+ )
99
164
 
100
165
  async def config_resetstat(self) -> TOK:
101
166
  """
102
167
  Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
103
- See https://valkey.io/commands/config-resetstat/ for details.
168
+
169
+ See [valkey.io](https://valkey.io/commands/config-resetstat/) for details.
104
170
 
105
171
  Returns:
106
172
  OK: Returns "OK" to confirm that the statistics were successfully reset.
@@ -110,10 +176,13 @@ class StandaloneCommands(CoreCommands):
110
176
  async def config_rewrite(self) -> TOK:
111
177
  """
112
178
  Rewrite the configuration file with the current configuration.
113
- See https://valkey.io/commands/config-rewrite/ for details.
179
+
180
+ See [valkey.io](https://valkey.io/commands/config-rewrite/) for details.
114
181
 
115
182
  Returns:
116
- OK: OK is returned when the configuration was rewritten properly. Otherwise, an error is raised.
183
+ OK: OK is returned when the configuration was rewritten properly.
184
+
185
+ Otherwise, an error is raised.
117
186
  """
118
187
  return cast(TOK, await self._execute_command(RequestType.ConfigRewrite, []))
119
188
 
@@ -122,7 +191,8 @@ class StandaloneCommands(CoreCommands):
122
191
  ) -> int:
123
192
  """
124
193
  Returns the current connection id.
125
- See https://valkey.io/commands/client-id/ for more information.
194
+
195
+ See [valkey.io](https://valkey.io/commands/client-id/) for more information.
126
196
 
127
197
  Returns:
128
198
  int: the id of the client.
@@ -132,14 +202,17 @@ class StandaloneCommands(CoreCommands):
132
202
  async def ping(self, message: Optional[TEncodable] = None) -> bytes:
133
203
  """
134
204
  Ping the server.
135
- See https://valkey.io/commands/ping/ for more details.
205
+
206
+ See [valkey.io](https://valkey.io/commands/ping/) for more details.
136
207
 
137
208
  Args:
138
- message (Optional[TEncodable]): An optional message to include in the PING command. If not provided,
139
- the server will respond with b"PONG". If provided, the server will respond with a copy of the message.
209
+ message (Optional[TEncodable]): An optional message to include in the PING command. If not provided,
210
+ the server will respond with b"PONG". If provided, the server will respond with a copy of the message.
140
211
 
141
212
  Returns:
142
- bytes: b"PONG" if `message` is not provided, otherwise return a copy of `message`.
213
+ bytes: b"PONG" if `message` is not provided.
214
+
215
+ Otherwise return a copy of `message`.
143
216
 
144
217
  Examples:
145
218
  >>> await client.ping()
@@ -153,8 +226,9 @@ class StandaloneCommands(CoreCommands):
153
226
  async def config_get(self, parameters: List[TEncodable]) -> Dict[bytes, bytes]:
154
227
  """
155
228
  Get the values of configuration parameters.
156
- Starting from server version 7, command supports multiple parameters.
157
- See https://valkey.io/commands/config-get/ for details.
229
+ Starting from server version 7, command supports multiple parameters
230
+
231
+ See [valkey.io](https://valkey.io/commands/config-get/) for details.
158
232
 
159
233
  Args:
160
234
  parameters (List[TEncodable]): A list of configuration parameter names to retrieve values for.
@@ -177,14 +251,17 @@ class StandaloneCommands(CoreCommands):
177
251
  """
178
252
  Set configuration parameters to the specified values.
179
253
  Starting from server version 7, command supports multiple parameters.
180
- See https://valkey.io/commands/config-set/ for details.
254
+
255
+ See [valkey.io](https://valkey.io/commands/config-set/) for details.
181
256
 
182
257
  Args:
183
258
  parameters_map (Mapping[TEncodable, TEncodable]): A map consisting of configuration
184
- parameters and their respective values to set.
259
+ parameters and their respective values to set.
185
260
 
186
261
  Returns:
187
- OK: Returns OK if all configurations have been successfully set. Otherwise, raises an error.
262
+ OK: Returns OK if all configurations have been successfully set.
263
+
264
+ Otherwise, raises an error.
188
265
 
189
266
  Examples:
190
267
  >>> config_set({"timeout": "1000", "maxmemory": "1GB"})
@@ -198,11 +275,13 @@ class StandaloneCommands(CoreCommands):
198
275
  async def client_getname(self) -> Optional[bytes]:
199
276
  """
200
277
  Get the name of the primary's connection.
201
- See https://valkey.io/commands/client-getname/ for more details.
278
+
279
+ See [valkey.io](https://valkey.io/commands/client-getname/) for more details.
202
280
 
203
281
  Returns:
204
- Optional[bytes]: Returns the name of the client connection as a byte string if a name is set,
205
- or None if no name is assigned.
282
+ Optional[bytes]: Returns the name of the client connection as a byte string if a name is set.
283
+
284
+ `None` if no name is assigned.
206
285
 
207
286
  Examples:
208
287
  >>> await client.client_getname()
@@ -215,7 +294,8 @@ class StandaloneCommands(CoreCommands):
215
294
  async def dbsize(self) -> int:
216
295
  """
217
296
  Returns the number of keys in the currently selected database.
218
- See https://valkey.io/commands/dbsize for more details.
297
+
298
+ See [valkey.io](https://valkey.io/commands/dbsize) for more details.
219
299
 
220
300
  Returns:
221
301
  int: The number of keys in the currently selected database.
@@ -230,7 +310,7 @@ class StandaloneCommands(CoreCommands):
230
310
  """
231
311
  Echoes the provided `message` back.
232
312
 
233
- See https://valkey.io/commands/echo for more details.
313
+ See [valkey.io](https://valkey.io/commands/echo) for more details.
234
314
 
235
315
  Args:
236
316
  message (TEncodable): The message to be echoed back.
@@ -250,7 +330,7 @@ class StandaloneCommands(CoreCommands):
250
330
  """
251
331
  Loads a library to Valkey.
252
332
 
253
- See https://valkey.io/commands/function-load/ for more details.
333
+ See [valkey.io](https://valkey.io/commands/function-load/) for more details.
254
334
 
255
335
  Args:
256
336
  library_code (TEncodable): The source code that implements the library.
@@ -261,7 +341,7 @@ class StandaloneCommands(CoreCommands):
261
341
  bytes: The library name that was loaded.
262
342
 
263
343
  Examples:
264
- >>> code = "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)"
344
+ >>> code = "#!lua name=mylib \\n redis.register_function('myfunc', function(keys, args) return args[1] end)"
265
345
  >>> await client.function_load(code, True)
266
346
  b"mylib"
267
347
 
@@ -281,7 +361,7 @@ class StandaloneCommands(CoreCommands):
281
361
  """
282
362
  Returns information about the functions and libraries.
283
363
 
284
- See https://valkey.io/commands/function-list/ for more details.
364
+ See [valkey.io](https://valkey.io/commands/function-list/) for more details.
285
365
 
286
366
  Args:
287
367
  library_name_pattern (Optional[TEncodable]): A wildcard pattern for matching library names.
@@ -289,7 +369,7 @@ class StandaloneCommands(CoreCommands):
289
369
 
290
370
  Returns:
291
371
  TFunctionListResponse: Info about all or
292
- selected libraries and their functions.
372
+ selected libraries and their functions.
293
373
 
294
374
  Examples:
295
375
  >>> response = await client.function_list("myLib?_backup", True)
@@ -301,7 +381,8 @@ class StandaloneCommands(CoreCommands):
301
381
  b"description": None,
302
382
  b"flags": {b"no-writes"},
303
383
  }],
304
- b"library_code": b"#!lua name=mylib \n sever.register_function('myfunc', function(keys, args) return args[1] end)"
384
+ b"library_code": b"#!lua name=mylib \\n sever.register_function('myfunc', function(keys, args) " \
385
+ b"return args[1] end)"
305
386
  }]
306
387
 
307
388
  Since: Valkey 7.0.0.
@@ -323,7 +404,7 @@ class StandaloneCommands(CoreCommands):
323
404
  """
324
405
  Deletes all function libraries.
325
406
 
326
- See https://valkey.io/commands/function-flush/ for more details.
407
+ See [valkey.io](https://valkey.io/commands/function-flush/) for more details.
327
408
 
328
409
  Args:
329
410
  mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -349,7 +430,7 @@ class StandaloneCommands(CoreCommands):
349
430
  """
350
431
  Deletes a library and all its functions.
351
432
 
352
- See https://valkey.io/commands/function-delete/ for more details.
433
+ See [valkey.io](https://valkey.io/commands/function-delete/) for more details.
353
434
 
354
435
  Args:
355
436
  library_code (TEncodable): The library name to delete
@@ -378,7 +459,7 @@ class StandaloneCommands(CoreCommands):
378
459
 
379
460
  FUNCTION KILL runs on all nodes of the server, including primary and replicas.
380
461
 
381
- See https://valkey.io/commands/function-kill/ for more details.
462
+ See [valkey.io](https://valkey.io/commands/function-kill/) for more details.
382
463
 
383
464
  Returns:
384
465
  TOK: A simple `OK`.
@@ -402,13 +483,15 @@ class StandaloneCommands(CoreCommands):
402
483
  FUNCTION STATS runs on all nodes of the server, including primary and replicas.
403
484
  The response includes a mapping from node address to the command response for that node.
404
485
 
405
- See https://valkey.io/commands/function-stats/ for more details
486
+ See [valkey.io](https://valkey.io/commands/function-stats/) for more details
406
487
 
407
488
  Returns:
408
489
  TFunctionStatsFullResponse: A Map where the key is the node address and the value is a Map of two keys:
490
+
409
491
  - `running_script` with information about the running script.
410
492
  - `engines` with information about available engines and their stats.
411
- See example for more details.
493
+
494
+ See example for more details.
412
495
 
413
496
  Examples:
414
497
  >>> await client.function_stats()
@@ -446,7 +529,7 @@ class StandaloneCommands(CoreCommands):
446
529
  """
447
530
  Returns the serialized payload of all loaded libraries.
448
531
 
449
- See https://valkey.io/docs/latest/commands/function-dump/ for more details.
532
+ See [valkey.io](https://valkey.io/docs/latest/commands/function-dump/) for more details.
450
533
 
451
534
  Returns:
452
535
  bytes: The serialized payload of all loaded libraries.
@@ -468,7 +551,7 @@ class StandaloneCommands(CoreCommands):
468
551
  """
469
552
  Restores libraries from the serialized payload returned by the `function_dump` command.
470
553
 
471
- See https://valkey.io/docs/latest/commands/function-restore/ for more details.
554
+ See [valkey.io](https://valkey.io/docs/latest/commands/function-restore/) for more details.
472
555
 
473
556
  Args:
474
557
  payload (TEncodable): The serialized data from the `function_dump` command.
@@ -498,7 +581,7 @@ class StandaloneCommands(CoreCommands):
498
581
  """
499
582
  Returns the server time.
500
583
 
501
- See https://valkey.io/commands/time/ for more details.
584
+ See [valkey.io](https://valkey.io/commands/time/) for more details.
502
585
 
503
586
  Returns:
504
587
  List[bytes]: The current server time as a two items `array`:
@@ -518,7 +601,7 @@ class StandaloneCommands(CoreCommands):
518
601
  """
519
602
  Returns the Unix time of the last DB save timestamp or startup timestamp if no save was made since then.
520
603
 
521
- See https://valkey.io/commands/lastsave for more details.
604
+ See [valkey.io](https://valkey.io/commands/lastsave) for more details.
522
605
 
523
606
  Returns:
524
607
  int: The Unix time of the last successful DB save.
@@ -532,33 +615,11 @@ class StandaloneCommands(CoreCommands):
532
615
  await self._execute_command(RequestType.LastSave, []),
533
616
  )
534
617
 
535
- async def move(self, key: TEncodable, db_index: int) -> bool:
536
- """
537
- Move `key` from the currently selected database to the database specified by `db_index`.
538
-
539
- See https://valkey.io/commands/move/ for more details.
540
-
541
- Args:
542
- key (TEncodable): The key to move.
543
- db_index (int): The index of the database to move `key` to.
544
-
545
- Returns:
546
- bool: True if `key` was moved, or False if the `key` already exists in the destination database
547
- or does not exist in the source database.
548
-
549
- Example:
550
- >>> await client.move("some_key", 1)
551
- True
552
- """
553
- return cast(
554
- bool,
555
- await self._execute_command(RequestType.Move, [key, str(db_index)]),
556
- )
557
-
558
618
  async def publish(self, message: TEncodable, channel: TEncodable) -> int:
559
619
  """
560
620
  Publish a message on pubsub channel.
561
- See https://valkey.io/commands/publish for more details.
621
+
622
+ See [valkey.io](https://valkey.io/commands/publish) for more details.
562
623
 
563
624
  Args:
564
625
  message (TEncodable): Message to publish
@@ -566,7 +627,8 @@ class StandaloneCommands(CoreCommands):
566
627
 
567
628
  Returns:
568
629
  int: Number of subscriptions in primary node that received the message.
569
- Note that this value does not include subscriptions that configured on replicas.
630
+
631
+ **Note:** this value does not include subscriptions that configured on replicas.
570
632
 
571
633
  Examples:
572
634
  >>> await client.publish("Hi all!", "global-channel")
@@ -580,7 +642,7 @@ class StandaloneCommands(CoreCommands):
580
642
  """
581
643
  Deletes all the keys of all the existing databases. This command never fails.
582
644
 
583
- See https://valkey.io/commands/flushall for more details.
645
+ See [valkey.io](https://valkey.io/commands/flushall) for more details.
584
646
 
585
647
  Args:
586
648
  flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -605,7 +667,7 @@ class StandaloneCommands(CoreCommands):
605
667
  """
606
668
  Deletes all the keys of the currently selected database. This command never fails.
607
669
 
608
- See https://valkey.io/commands/flushdb for more details.
670
+ See [valkey.io](https://valkey.io/commands/flushdb) for more details.
609
671
 
610
672
  Args:
611
673
  flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -641,7 +703,7 @@ class StandaloneCommands(CoreCommands):
641
703
  otherwise the current database will be used. When `replace` is True, removes the
642
704
  `destination` key first if it already exists, otherwise performs no action.
643
705
 
644
- See https://valkey.io/commands/copy for more details.
706
+ See [valkey.io](https://valkey.io/commands/copy) for more details.
645
707
 
646
708
  Args:
647
709
  source (TEncodable): The key to the source value.
@@ -650,7 +712,9 @@ class StandaloneCommands(CoreCommands):
650
712
  replace (Optional[bool]): If the destination key should be removed before copying the value to it.
651
713
 
652
714
  Returns:
653
- bool: True if the source was copied. Otherwise, return False.
715
+ bool: True if the source was copied.
716
+
717
+ Otherwise, return False.
654
718
 
655
719
  Examples:
656
720
  >>> await client.set("source", "sheep")
@@ -680,13 +744,14 @@ class StandaloneCommands(CoreCommands):
680
744
  """
681
745
  Displays a piece of generative computer art and the Valkey version.
682
746
 
683
- See https://valkey.io/commands/lolwut for more details.
747
+ See [valkey.io](https://valkey.io/commands/lolwut) for more details.
684
748
 
685
749
  Args:
686
750
  version (Optional[int]): Version of computer art to generate.
687
751
  parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
688
- For version `5`, those are length of the line, number of squares per row, and number of squares per column.
689
- For version `6`, those are number of columns and number of lines.
752
+
753
+ - For version `5`, those are length of the line, number of squares per row, and number of squares per column.
754
+ - For version `6`, those are number of columns and number of lines.
690
755
 
691
756
  Returns:
692
757
  bytes: A piece of generative computer art along with the current Valkey version.
@@ -702,7 +767,7 @@ class StandaloneCommands(CoreCommands):
702
767
  args.extend(["VERSION", str(version)])
703
768
  if parameters:
704
769
  for var in parameters:
705
- args.extend(str(var))
770
+ args.append(str(var))
706
771
  return cast(
707
772
  bytes,
708
773
  await self._execute_command(RequestType.Lolwut, args),
@@ -712,7 +777,7 @@ class StandaloneCommands(CoreCommands):
712
777
  """
713
778
  Returns a random existing key name from the currently selected database.
714
779
 
715
- See https://valkey.io/commands/randomkey for more details.
780
+ See [valkey.io](https://valkey.io/commands/randomkey) for more details.
716
781
 
717
782
  Returns:
718
783
  Optional[bytes]: A random existing key name from the currently selected database.
@@ -736,7 +801,7 @@ class StandaloneCommands(CoreCommands):
736
801
  and acknowledged by at least `numreplicas` of replicas. If `timeout` is
737
802
  reached, the command returns even if the specified number of replicas were not yet reached.
738
803
 
739
- See https://valkey.io/commands/wait for more details.
804
+ See [valkey.io](https://valkey.io/commands/wait) for more details.
740
805
 
741
806
  Args:
742
807
  numreplicas (int): The number of replicas to reach.
@@ -748,7 +813,7 @@ class StandaloneCommands(CoreCommands):
748
813
  Examples:
749
814
  >>> await client.set("key", "value");
750
815
  >>> await client.wait(1, 1000);
751
- // return 1 when a replica is reached or 0 if 1000ms is reached.
816
+ # return 1 when a replica is reached or 0 if 1000ms is reached.
752
817
  """
753
818
  args: List[TEncodable] = [str(numreplicas), str(timeout)]
754
819
  return cast(
@@ -758,17 +823,15 @@ class StandaloneCommands(CoreCommands):
758
823
 
759
824
  async def unwatch(self) -> TOK:
760
825
  """
761
- Flushes all the previously watched keys for a transaction. Executing a transaction will
826
+ Flushes all the previously watched keys for an atomic batch (Transaction). Executing a transaction will
762
827
  automatically flush all previously watched keys.
763
828
 
764
- See https://valkey.io/commands/unwatch for more details.
829
+ See [valkey.io](https://valkey.io/commands/unwatch) for more details.
765
830
 
766
831
  Returns:
767
832
  TOK: A simple "OK" response.
768
833
 
769
834
  Examples:
770
- >>> await client.watch("sampleKey")
771
- 'OK'
772
835
  >>> await client.unwatch()
773
836
  'OK'
774
837
  """
@@ -794,41 +857,43 @@ class StandaloneCommands(CoreCommands):
794
857
  in the collection from the start to the end of a full iteration.
795
858
  Elements that were not constantly present in the collection during a full iteration, may be returned or not.
796
859
 
797
- See https://valkey.io/commands/scan for more details.
860
+ See [valkey.io](https://valkey.io/commands/scan) for more details.
798
861
 
799
862
  Args:
800
863
  cursor (TResult): The cursor used for iteration. For the first iteration, the cursor should be set to "0".
801
- Using a non-zero cursor in the first iteration,
802
- or an invalid cursor at any iteration, will lead to undefined results.
803
- Using the same cursor in multiple iterations will, in case nothing changed between the iterations,
804
- return the same elements multiple times.
805
- If the the db has changed, it may result an undefined behavior.
864
+
865
+ - Using a non-zero cursor in the first iteration, or an invalid cursor at any iteration, will lead to
866
+ undefined results.
867
+ - Using the same cursor in multiple iterations will, in case nothing changed between the iterations,
868
+ return the same elements multiple times.
869
+ - If the the db has changed, it may result an undefined behavior.
870
+
806
871
  match (Optional[TResult]): A pattern to match keys against.
807
872
  count (Optional[int]): The number of keys to return per iteration.
808
- The number of keys returned per iteration is not guaranteed to be the same as the count argument.
809
- the argument is used as a hint for the server to know how many "steps" it can use to retrieve the keys.
810
- The default value is 10.
873
+
874
+ - The number of keys returned per iteration is not guaranteed to be the same as the count argument.
875
+ - The argument is used as a hint for the server to know how many "steps" it can use to retrieve the keys.
876
+ - The default value is 10.
877
+
811
878
  type (ObjectType): The type of object to scan for.
812
879
 
813
880
  Returns:
814
881
  List[Union[bytes, List[bytes]]]: A List containing the next cursor value and a list of keys,
815
- formatted as [cursor, [key1, key2, ...]]
882
+ formatted as [cursor, [key1, key2, ...]]
816
883
 
817
884
  Examples:
818
- >>> result = await client.scan(b'0')
819
- print(result) #[b'17', [b'key1', b'key2', b'key3', b'key4', b'key5', b'set1', b'set2', b'set3']]
820
- first_cursor_result = result[0]
821
- result = await client.scan(first_cursor_result)
822
- print(result) #[b'349', [b'key4', b'key5', b'set1', b'hash1', b'zset1', b'list1', b'list2',
823
- b'list3', b'zset2', b'zset3', b'zset4', b'zset5', b'zset6']]
824
- result = await client.scan(result[0])
825
- print(result) #[b'0', [b'key6', b'key7']]
826
-
827
- >>> result = await client.scan(first_cursor_result, match=b'key*', count=2)
828
- print(result) #[b'6', [b'key4', b'key5']]
829
-
830
- >>> result = await client.scan("0", type=ObjectType.Set)
831
- print(result) #[b'362', [b'set1', b'set2', b'set3']]
885
+ >>> result = await client.scan(b'0')
886
+ print(result) #[b'17', [b'key1', b'key2', b'key3', b'key4', b'key5', b'set1', b'set2', b'set3']]
887
+ first_cursor_result = result[0]
888
+ result = await client.scan(first_cursor_result)
889
+ print(result) #[b'349', [b'key4', b'key5', b'set1', b'hash1', b'zset1', b'list1', b'list2',
890
+ b'list3', b'zset2', b'zset3', b'zset4', b'zset5', b'zset6']]
891
+ result = await client.scan(result[0])
892
+ print(result) #[b'0', [b'key6', b'key7']]
893
+ >>> result = await client.scan(first_cursor_result, match=b'key*', count=2)
894
+ print(result) #[b'6', [b'key4', b'key5']]
895
+ >>> result = await client.scan("0", type=ObjectType.Set)
896
+ print(result) #[b'362', [b'set1', b'set2', b'set3']]
832
897
  """
833
898
  args = [cursor]
834
899
  if match:
@@ -846,7 +911,7 @@ class StandaloneCommands(CoreCommands):
846
911
  """
847
912
  Check existence of scripts in the script cache by their SHA1 digest.
848
913
 
849
- See https://valkey.io/commands/script-exists for more details.
914
+ See [valkey.io](https://valkey.io/commands/script-exists) for more details.
850
915
 
851
916
  Args:
852
917
  sha1s (List[TEncodable]): List of SHA1 digests of the scripts to check.
@@ -866,7 +931,7 @@ class StandaloneCommands(CoreCommands):
866
931
  """
867
932
  Flush the Lua scripts cache.
868
933
 
869
- See https://valkey.io/commands/script-flush for more details.
934
+ See [valkey.io](https://valkey.io/commands/script-flush) for more details.
870
935
 
871
936
  Args:
872
937
  mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -893,7 +958,7 @@ class StandaloneCommands(CoreCommands):
893
958
  """
894
959
  Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
895
960
 
896
- See https://valkey.io/commands/script-kill for more details.
961
+ See [valkey.io](https://valkey.io/commands/script-kill) for more details.
897
962
 
898
963
  Returns:
899
964
  TOK: A simple `OK` response.
@@ -917,7 +982,8 @@ class StandaloneCommands(CoreCommands):
917
982
  If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
918
983
  After that, it will be invoked using the `EVALSHA` command.
919
984
 
920
- See https://valkey.io/commands/script-load/ and https://valkey.io/commands/evalsha/ for more details.
985
+ See [SCRIPT LOAD](https://valkey.io/commands/script-load/) and [EVALSHA](https://valkey.io/commands/evalsha/)
986
+ for more details.
921
987
 
922
988
  Args:
923
989
  script (Script): The Lua script to execute.
@@ -929,7 +995,7 @@ class StandaloneCommands(CoreCommands):
929
995
 
930
996
  Examples:
931
997
  >>> lua_script = Script("return { KEYS[1], ARGV[1] }")
932
- >>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"] );
998
+ >>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"])
933
999
  [b"foo", b"bar"]
934
1000
  """
935
1001
  return await self._execute_script(script.get_hash(), keys, args)