valkey-glide 1.2.0rc14__cp311-cp311-macosx_11_0_arm64.whl → 2.2.3__cp311-cp311-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 +169 -104
  2. glide/async_commands/cluster_commands.py +367 -172
  3. glide/async_commands/core.py +1808 -1026
  4. glide/async_commands/{server_modules/ft.py → ft.py} +91 -21
  5. glide/async_commands/{server_modules/glide_json.py → glide_json.py} +161 -146
  6. glide/async_commands/standalone_commands.py +204 -136
  7. glide/glide.cpython-311-darwin.so +0 -0
  8. glide/glide.pyi +26 -1
  9. glide/glide_client.py +355 -136
  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 +1845 -1059
  15. glide_shared/commands/batch_options.py +261 -0
  16. {glide/async_commands → glide_shared/commands}/bitmap.py +96 -86
  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 +17 -9
  23. glide_shared/commands/server_modules/json_batch.py +820 -0
  24. glide_shared/commands/server_modules/json_options.py +93 -0
  25. {glide/async_commands → glide_shared/commands}/sorted_set.py +42 -32
  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.3.dist-info/METADATA +211 -0
  36. valkey_glide-2.2.3.dist-info/RECORD +40 -0
  37. {valkey_glide-1.2.0rc14.dist-info → valkey_glide-2.2.3.dist-info}/WHEEL +1 -1
  38. glide/config.py +0 -521
  39. glide/protobuf/command_request_pb2.py +0 -54
  40. glide/protobuf/command_request_pb2.pyi +0 -1161
  41. glide/protobuf/connection_request_pb2.py +0 -52
  42. glide/protobuf/connection_request_pb2.pyi +0 -287
  43. glide/protobuf/response_pb2.pyi +0 -101
  44. glide/routes.py +0 -114
  45. valkey_glide-1.2.0rc14.dist-info/METADATA +0 -122
  46. valkey_glide-1.2.0rc14.dist-info/RECORD +0 -36
  47. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +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,7 +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
- 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.
157
232
 
158
233
  Args:
159
234
  parameters (List[TEncodable]): A list of configuration parameter names to retrieve values for.
@@ -175,14 +250,18 @@ class StandaloneCommands(CoreCommands):
175
250
  async def config_set(self, parameters_map: Mapping[TEncodable, TEncodable]) -> TOK:
176
251
  """
177
252
  Set configuration parameters to the specified values.
178
- See https://valkey.io/commands/config-set/ for details.
253
+ Starting from server version 7, command supports multiple parameters.
254
+
255
+ See [valkey.io](https://valkey.io/commands/config-set/) for details.
179
256
 
180
257
  Args:
181
258
  parameters_map (Mapping[TEncodable, TEncodable]): A map consisting of configuration
182
- parameters and their respective values to set.
259
+ parameters and their respective values to set.
183
260
 
184
261
  Returns:
185
- 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.
186
265
 
187
266
  Examples:
188
267
  >>> config_set({"timeout": "1000", "maxmemory": "1GB"})
@@ -196,11 +275,13 @@ class StandaloneCommands(CoreCommands):
196
275
  async def client_getname(self) -> Optional[bytes]:
197
276
  """
198
277
  Get the name of the primary's connection.
199
- See https://valkey.io/commands/client-getname/ for more details.
278
+
279
+ See [valkey.io](https://valkey.io/commands/client-getname/) for more details.
200
280
 
201
281
  Returns:
202
- Optional[bytes]: Returns the name of the client connection as a byte string if a name is set,
203
- 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.
204
285
 
205
286
  Examples:
206
287
  >>> await client.client_getname()
@@ -213,7 +294,8 @@ class StandaloneCommands(CoreCommands):
213
294
  async def dbsize(self) -> int:
214
295
  """
215
296
  Returns the number of keys in the currently selected database.
216
- See https://valkey.io/commands/dbsize for more details.
297
+
298
+ See [valkey.io](https://valkey.io/commands/dbsize) for more details.
217
299
 
218
300
  Returns:
219
301
  int: The number of keys in the currently selected database.
@@ -228,7 +310,7 @@ class StandaloneCommands(CoreCommands):
228
310
  """
229
311
  Echoes the provided `message` back.
230
312
 
231
- See https://valkey.io/commands/echo for more details.
313
+ See [valkey.io](https://valkey.io/commands/echo) for more details.
232
314
 
233
315
  Args:
234
316
  message (TEncodable): The message to be echoed back.
@@ -248,7 +330,7 @@ class StandaloneCommands(CoreCommands):
248
330
  """
249
331
  Loads a library to Valkey.
250
332
 
251
- See https://valkey.io/commands/function-load/ for more details.
333
+ See [valkey.io](https://valkey.io/commands/function-load/) for more details.
252
334
 
253
335
  Args:
254
336
  library_code (TEncodable): The source code that implements the library.
@@ -259,7 +341,7 @@ class StandaloneCommands(CoreCommands):
259
341
  bytes: The library name that was loaded.
260
342
 
261
343
  Examples:
262
- >>> 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)"
263
345
  >>> await client.function_load(code, True)
264
346
  b"mylib"
265
347
 
@@ -279,7 +361,7 @@ class StandaloneCommands(CoreCommands):
279
361
  """
280
362
  Returns information about the functions and libraries.
281
363
 
282
- See https://valkey.io/commands/function-list/ for more details.
364
+ See [valkey.io](https://valkey.io/commands/function-list/) for more details.
283
365
 
284
366
  Args:
285
367
  library_name_pattern (Optional[TEncodable]): A wildcard pattern for matching library names.
@@ -287,7 +369,7 @@ class StandaloneCommands(CoreCommands):
287
369
 
288
370
  Returns:
289
371
  TFunctionListResponse: Info about all or
290
- selected libraries and their functions.
372
+ selected libraries and their functions.
291
373
 
292
374
  Examples:
293
375
  >>> response = await client.function_list("myLib?_backup", True)
@@ -299,7 +381,8 @@ class StandaloneCommands(CoreCommands):
299
381
  b"description": None,
300
382
  b"flags": {b"no-writes"},
301
383
  }],
302
- 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)"
303
386
  }]
304
387
 
305
388
  Since: Valkey 7.0.0.
@@ -321,7 +404,7 @@ class StandaloneCommands(CoreCommands):
321
404
  """
322
405
  Deletes all function libraries.
323
406
 
324
- See https://valkey.io/commands/function-flush/ for more details.
407
+ See [valkey.io](https://valkey.io/commands/function-flush/) for more details.
325
408
 
326
409
  Args:
327
410
  mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -347,7 +430,7 @@ class StandaloneCommands(CoreCommands):
347
430
  """
348
431
  Deletes a library and all its functions.
349
432
 
350
- See https://valkey.io/commands/function-delete/ for more details.
433
+ See [valkey.io](https://valkey.io/commands/function-delete/) for more details.
351
434
 
352
435
  Args:
353
436
  library_code (TEncodable): The library name to delete
@@ -376,7 +459,7 @@ class StandaloneCommands(CoreCommands):
376
459
 
377
460
  FUNCTION KILL runs on all nodes of the server, including primary and replicas.
378
461
 
379
- See https://valkey.io/commands/function-kill/ for more details.
462
+ See [valkey.io](https://valkey.io/commands/function-kill/) for more details.
380
463
 
381
464
  Returns:
382
465
  TOK: A simple `OK`.
@@ -400,13 +483,15 @@ class StandaloneCommands(CoreCommands):
400
483
  FUNCTION STATS runs on all nodes of the server, including primary and replicas.
401
484
  The response includes a mapping from node address to the command response for that node.
402
485
 
403
- See https://valkey.io/commands/function-stats/ for more details
486
+ See [valkey.io](https://valkey.io/commands/function-stats/) for more details
404
487
 
405
488
  Returns:
406
489
  TFunctionStatsFullResponse: A Map where the key is the node address and the value is a Map of two keys:
490
+
407
491
  - `running_script` with information about the running script.
408
492
  - `engines` with information about available engines and their stats.
409
- See example for more details.
493
+
494
+ See example for more details.
410
495
 
411
496
  Examples:
412
497
  >>> await client.function_stats()
@@ -444,7 +529,7 @@ class StandaloneCommands(CoreCommands):
444
529
  """
445
530
  Returns the serialized payload of all loaded libraries.
446
531
 
447
- 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.
448
533
 
449
534
  Returns:
450
535
  bytes: The serialized payload of all loaded libraries.
@@ -466,7 +551,7 @@ class StandaloneCommands(CoreCommands):
466
551
  """
467
552
  Restores libraries from the serialized payload returned by the `function_dump` command.
468
553
 
469
- 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.
470
555
 
471
556
  Args:
472
557
  payload (TEncodable): The serialized data from the `function_dump` command.
@@ -496,7 +581,7 @@ class StandaloneCommands(CoreCommands):
496
581
  """
497
582
  Returns the server time.
498
583
 
499
- See https://valkey.io/commands/time/ for more details.
584
+ See [valkey.io](https://valkey.io/commands/time/) for more details.
500
585
 
501
586
  Returns:
502
587
  List[bytes]: The current server time as a two items `array`:
@@ -516,7 +601,7 @@ class StandaloneCommands(CoreCommands):
516
601
  """
517
602
  Returns the Unix time of the last DB save timestamp or startup timestamp if no save was made since then.
518
603
 
519
- See https://valkey.io/commands/lastsave for more details.
604
+ See [valkey.io](https://valkey.io/commands/lastsave) for more details.
520
605
 
521
606
  Returns:
522
607
  int: The Unix time of the last successful DB save.
@@ -530,33 +615,11 @@ class StandaloneCommands(CoreCommands):
530
615
  await self._execute_command(RequestType.LastSave, []),
531
616
  )
532
617
 
533
- async def move(self, key: TEncodable, db_index: int) -> bool:
534
- """
535
- Move `key` from the currently selected database to the database specified by `db_index`.
536
-
537
- See https://valkey.io/commands/move/ for more details.
538
-
539
- Args:
540
- key (TEncodable): The key to move.
541
- db_index (int): The index of the database to move `key` to.
542
-
543
- Returns:
544
- bool: True if `key` was moved, or False if the `key` already exists in the destination database
545
- or does not exist in the source database.
546
-
547
- Example:
548
- >>> await client.move("some_key", 1)
549
- True
550
- """
551
- return cast(
552
- bool,
553
- await self._execute_command(RequestType.Move, [key, str(db_index)]),
554
- )
555
-
556
618
  async def publish(self, message: TEncodable, channel: TEncodable) -> int:
557
619
  """
558
620
  Publish a message on pubsub channel.
559
- See https://valkey.io/commands/publish for more details.
621
+
622
+ See [valkey.io](https://valkey.io/commands/publish) for more details.
560
623
 
561
624
  Args:
562
625
  message (TEncodable): Message to publish
@@ -564,7 +627,8 @@ class StandaloneCommands(CoreCommands):
564
627
 
565
628
  Returns:
566
629
  int: Number of subscriptions in primary node that received the message.
567
- 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.
568
632
 
569
633
  Examples:
570
634
  >>> await client.publish("Hi all!", "global-channel")
@@ -578,7 +642,7 @@ class StandaloneCommands(CoreCommands):
578
642
  """
579
643
  Deletes all the keys of all the existing databases. This command never fails.
580
644
 
581
- See https://valkey.io/commands/flushall for more details.
645
+ See [valkey.io](https://valkey.io/commands/flushall) for more details.
582
646
 
583
647
  Args:
584
648
  flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -603,7 +667,7 @@ class StandaloneCommands(CoreCommands):
603
667
  """
604
668
  Deletes all the keys of the currently selected database. This command never fails.
605
669
 
606
- See https://valkey.io/commands/flushdb for more details.
670
+ See [valkey.io](https://valkey.io/commands/flushdb) for more details.
607
671
 
608
672
  Args:
609
673
  flush_mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -639,7 +703,7 @@ class StandaloneCommands(CoreCommands):
639
703
  otherwise the current database will be used. When `replace` is True, removes the
640
704
  `destination` key first if it already exists, otherwise performs no action.
641
705
 
642
- See https://valkey.io/commands/copy for more details.
706
+ See [valkey.io](https://valkey.io/commands/copy) for more details.
643
707
 
644
708
  Args:
645
709
  source (TEncodable): The key to the source value.
@@ -648,7 +712,9 @@ class StandaloneCommands(CoreCommands):
648
712
  replace (Optional[bool]): If the destination key should be removed before copying the value to it.
649
713
 
650
714
  Returns:
651
- bool: True if the source was copied. Otherwise, return False.
715
+ bool: True if the source was copied.
716
+
717
+ Otherwise, return False.
652
718
 
653
719
  Examples:
654
720
  >>> await client.set("source", "sheep")
@@ -678,13 +744,14 @@ class StandaloneCommands(CoreCommands):
678
744
  """
679
745
  Displays a piece of generative computer art and the Valkey version.
680
746
 
681
- See https://valkey.io/commands/lolwut for more details.
747
+ See [valkey.io](https://valkey.io/commands/lolwut) for more details.
682
748
 
683
749
  Args:
684
750
  version (Optional[int]): Version of computer art to generate.
685
751
  parameters (Optional[List[int]]): Additional set of arguments in order to change the output:
686
- For version `5`, those are length of the line, number of squares per row, and number of squares per column.
687
- 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.
688
755
 
689
756
  Returns:
690
757
  bytes: A piece of generative computer art along with the current Valkey version.
@@ -700,7 +767,7 @@ class StandaloneCommands(CoreCommands):
700
767
  args.extend(["VERSION", str(version)])
701
768
  if parameters:
702
769
  for var in parameters:
703
- args.extend(str(var))
770
+ args.append(str(var))
704
771
  return cast(
705
772
  bytes,
706
773
  await self._execute_command(RequestType.Lolwut, args),
@@ -710,7 +777,7 @@ class StandaloneCommands(CoreCommands):
710
777
  """
711
778
  Returns a random existing key name from the currently selected database.
712
779
 
713
- See https://valkey.io/commands/randomkey for more details.
780
+ See [valkey.io](https://valkey.io/commands/randomkey) for more details.
714
781
 
715
782
  Returns:
716
783
  Optional[bytes]: A random existing key name from the currently selected database.
@@ -734,7 +801,7 @@ class StandaloneCommands(CoreCommands):
734
801
  and acknowledged by at least `numreplicas` of replicas. If `timeout` is
735
802
  reached, the command returns even if the specified number of replicas were not yet reached.
736
803
 
737
- See https://valkey.io/commands/wait for more details.
804
+ See [valkey.io](https://valkey.io/commands/wait) for more details.
738
805
 
739
806
  Args:
740
807
  numreplicas (int): The number of replicas to reach.
@@ -746,7 +813,7 @@ class StandaloneCommands(CoreCommands):
746
813
  Examples:
747
814
  >>> await client.set("key", "value");
748
815
  >>> await client.wait(1, 1000);
749
- // 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.
750
817
  """
751
818
  args: List[TEncodable] = [str(numreplicas), str(timeout)]
752
819
  return cast(
@@ -756,17 +823,15 @@ class StandaloneCommands(CoreCommands):
756
823
 
757
824
  async def unwatch(self) -> TOK:
758
825
  """
759
- 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
760
827
  automatically flush all previously watched keys.
761
828
 
762
- See https://valkey.io/commands/unwatch for more details.
829
+ See [valkey.io](https://valkey.io/commands/unwatch) for more details.
763
830
 
764
831
  Returns:
765
832
  TOK: A simple "OK" response.
766
833
 
767
834
  Examples:
768
- >>> await client.watch("sampleKey")
769
- 'OK'
770
835
  >>> await client.unwatch()
771
836
  'OK'
772
837
  """
@@ -792,41 +857,43 @@ class StandaloneCommands(CoreCommands):
792
857
  in the collection from the start to the end of a full iteration.
793
858
  Elements that were not constantly present in the collection during a full iteration, may be returned or not.
794
859
 
795
- See https://valkey.io/commands/scan for more details.
860
+ See [valkey.io](https://valkey.io/commands/scan) for more details.
796
861
 
797
862
  Args:
798
863
  cursor (TResult): The cursor used for iteration. For the first iteration, the cursor should be set to "0".
799
- Using a non-zero cursor in the first iteration,
800
- or an invalid cursor at any iteration, will lead to undefined results.
801
- Using the same cursor in multiple iterations will, in case nothing changed between the iterations,
802
- return the same elements multiple times.
803
- 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
+
804
871
  match (Optional[TResult]): A pattern to match keys against.
805
872
  count (Optional[int]): The number of keys to return per iteration.
806
- The number of keys returned per iteration is not guaranteed to be the same as the count argument.
807
- the argument is used as a hint for the server to know how many "steps" it can use to retrieve the keys.
808
- 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
+
809
878
  type (ObjectType): The type of object to scan for.
810
879
 
811
880
  Returns:
812
881
  List[Union[bytes, List[bytes]]]: A List containing the next cursor value and a list of keys,
813
- formatted as [cursor, [key1, key2, ...]]
882
+ formatted as [cursor, [key1, key2, ...]]
814
883
 
815
884
  Examples:
816
- >>> result = await client.scan(b'0')
817
- print(result) #[b'17', [b'key1', b'key2', b'key3', b'key4', b'key5', b'set1', b'set2', b'set3']]
818
- first_cursor_result = result[0]
819
- result = await client.scan(first_cursor_result)
820
- print(result) #[b'349', [b'key4', b'key5', b'set1', b'hash1', b'zset1', b'list1', b'list2',
821
- b'list3', b'zset2', b'zset3', b'zset4', b'zset5', b'zset6']]
822
- result = await client.scan(result[0])
823
- print(result) #[b'0', [b'key6', b'key7']]
824
-
825
- >>> result = await client.scan(first_cursor_result, match=b'key*', count=2)
826
- print(result) #[b'6', [b'key4', b'key5']]
827
-
828
- >>> result = await client.scan("0", type=ObjectType.Set)
829
- 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']]
830
897
  """
831
898
  args = [cursor]
832
899
  if match:
@@ -844,7 +911,7 @@ class StandaloneCommands(CoreCommands):
844
911
  """
845
912
  Check existence of scripts in the script cache by their SHA1 digest.
846
913
 
847
- See https://valkey.io/commands/script-exists for more details.
914
+ See [valkey.io](https://valkey.io/commands/script-exists) for more details.
848
915
 
849
916
  Args:
850
917
  sha1s (List[TEncodable]): List of SHA1 digests of the scripts to check.
@@ -864,7 +931,7 @@ class StandaloneCommands(CoreCommands):
864
931
  """
865
932
  Flush the Lua scripts cache.
866
933
 
867
- See https://valkey.io/commands/script-flush for more details.
934
+ See [valkey.io](https://valkey.io/commands/script-flush) for more details.
868
935
 
869
936
  Args:
870
937
  mode (Optional[FlushMode]): The flushing mode, could be either `SYNC` or `ASYNC`.
@@ -891,7 +958,7 @@ class StandaloneCommands(CoreCommands):
891
958
  """
892
959
  Kill the currently executing Lua script, assuming no write operation was yet performed by the script.
893
960
 
894
- See https://valkey.io/commands/script-kill for more details.
961
+ See [valkey.io](https://valkey.io/commands/script-kill) for more details.
895
962
 
896
963
  Returns:
897
964
  TOK: A simple `OK` response.
@@ -915,7 +982,8 @@ class StandaloneCommands(CoreCommands):
915
982
  If the script has not already been loaded, it will be loaded automatically using the `SCRIPT LOAD` command.
916
983
  After that, it will be invoked using the `EVALSHA` command.
917
984
 
918
- 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.
919
987
 
920
988
  Args:
921
989
  script (Script): The Lua script to execute.
@@ -927,7 +995,7 @@ class StandaloneCommands(CoreCommands):
927
995
 
928
996
  Examples:
929
997
  >>> lua_script = Script("return { KEYS[1], ARGV[1] }")
930
- >>> await invoke_script(lua_script, keys=["foo"], args=["bar"] );
998
+ >>> await client.invoke_script(lua_script, keys=["foo"], args=["bar"])
931
999
  [b"foo", b"bar"]
932
1000
  """
933
1001
  return await self._execute_script(script.get_hash(), keys, args)