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
@@ -1,15 +1,16 @@
1
1
  # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
- """Glide module for `JSON` commands in transaction.
2
+ """Glide module for `JSON` commands in batch.
3
3
 
4
4
  Examples:
5
5
  >>> import json
6
6
  >>> from glide import json_batch
7
- >>> transaction = ClusterTransaction()
7
+ >>> batch = ClusterBatch(is_atomic=True)
8
8
  >>> value = {'a': 1.0, 'b': 2}
9
9
  >>> json_str = json.dumps(value) # Convert Python dictionary to JSON string using json.dumps()
10
- >>> json_batch.set(transaction, "doc", "$", json_str)
11
- >>> json_batch.get(transaction, "doc", "$") # Returns the value at path '$' in the JSON document stored at `doc` as JSON string.
12
- >>> result = await glide_client.exec(transaction)
10
+ >>> json_batch.set(batch, "doc", "$", json_str)
11
+ >>> json_batch.get(batch, "doc", "$") # Returns the value at path '$' in the JSON document stored at `doc` as
12
+ # JSON string.
13
+ >>> result = await glide_client.exec(batch)
13
14
  >>> print result[0] # set result
14
15
  'OK' # Indicates successful setting of the value at path '$' in the key stored at `doc`.
15
16
  >>> print result[1] # get result
@@ -19,34 +20,34 @@ Examples:
19
20
 
20
21
  """
21
22
 
22
- from typing import List, Optional, Union, cast
23
+ from typing import List, Optional, Union
23
24
 
24
- from glide.async_commands.core import ConditionalChange
25
- from glide.async_commands.server_modules.glide_json import (
25
+ from glide_shared.commands.batch import TBatch
26
+ from glide_shared.commands.core_options import ConditionalChange
27
+ from glide_shared.commands.server_modules.json_options import (
26
28
  JsonArrIndexOptions,
27
29
  JsonArrPopOptions,
28
30
  JsonGetOptions,
29
31
  )
30
- from glide.async_commands.transaction import TTransaction
31
- from glide.constants import TEncodable
32
- from glide.protobuf.command_request_pb2 import RequestType
32
+ from glide_shared.constants import TEncodable
33
33
 
34
34
 
35
35
  def set(
36
- transaction: TTransaction,
36
+ batch: TBatch,
37
37
  key: TEncodable,
38
38
  path: TEncodable,
39
39
  value: TEncodable,
40
40
  set_condition: Optional[ConditionalChange] = None,
41
- ) -> TTransaction:
41
+ ) -> TBatch:
42
42
  """
43
43
  Sets the JSON value at the specified `path` stored at `key`.
44
44
 
45
45
  Args:
46
- transaction (TTransaction): The transaction to execute the command.
46
+ batch (TBatch): The batch to execute the command.
47
47
  key (TEncodable): The key of the JSON document.
48
48
  path (TEncodable): Represents the path within the JSON document where the value will be set.
49
- The key will be modified only if `value` is added as the last child in the specified `path`, or if the specified `path` acts as the parent of a new child being added.
49
+ The key will be modified only if `value` is added as the last child in the specified `path`, or if the specified
50
+ `path` acts as the parent of a new child being added.
50
51
  value (TEncodable): The value to set at the specific path, in JSON formatted bytes or str.
51
52
  set_condition (Optional[ConditionalChange]): Set the value only if the given condition is met (within the key or path).
52
53
  Equivalent to [`XX` | `NX`] in the RESP API. Defaults to None.
@@ -59,23 +60,25 @@ def set(
59
60
  if set_condition:
60
61
  args.append(set_condition.value)
61
62
 
62
- return transaction.custom_command(args)
63
+ return batch.custom_command(args)
63
64
 
64
65
 
65
66
  def get(
66
- transaction: TTransaction,
67
+ batch: TBatch,
67
68
  key: TEncodable,
68
69
  paths: Optional[Union[TEncodable, List[TEncodable]]] = None,
69
70
  options: Optional[JsonGetOptions] = None,
70
- ) -> TTransaction:
71
+ ) -> TBatch:
71
72
  """
72
73
  Retrieves the JSON value at the specified `paths` stored at `key`.
73
74
 
74
75
  Args:
75
- transaction (TTransaction): The transaction to execute the command.
76
+ batch (TBatch): The batch to execute the command.
76
77
  key (TEncodable): The key of the JSON document.
77
- paths (Optional[Union[TEncodable, List[TEncodable]]]): The path or list of paths within the JSON document. Default to None.
78
- options (Optional[JsonGetOptions]): Options for formatting the byte representation of the JSON data. See `JsonGetOptions`.
78
+ paths (Optional[Union[TEncodable, List[TEncodable]]]): The path or list of paths within the JSON document.
79
+ Default to None.
80
+ options (Optional[JsonGetOptions]): Options for formatting the byte representation of the JSON data.
81
+ See `JsonGetOptions`.
79
82
 
80
83
  Command response:
81
84
  TJsonResponse[Optional[bytes]]:
@@ -89,8 +92,10 @@ def get(
89
92
  If `path` doesn't exist, an error is raised.
90
93
  If `key` doesn't exist, returns None.
91
94
  If multiple paths are given:
92
- Returns a stringified JSON object in bytes, in which each path is a key, and it's corresponding value, is the value as if the path was executed in the command as a single path.
93
- In case of multiple paths, and `paths` are a mix of both JSONPath and legacy path, the command behaves as if all are JSONPath paths.
95
+ Returns a stringified JSON object in bytes, in which each path is a key, and it's corresponding value, is the
96
+ value as if the path was executed in the command as a single path.
97
+ In case of multiple paths, and `paths` are a mix of both JSONPath and legacy path, the command behaves as if all are
98
+ JSONPath paths.
94
99
  For more information about the returned type, see `TJsonResponse`.
95
100
  """
96
101
  args = ["JSON.GET", key]
@@ -101,22 +106,30 @@ def get(
101
106
  paths = [paths]
102
107
  args.extend(paths)
103
108
 
104
- return transaction.custom_command(args)
109
+ return batch.custom_command(args)
105
110
 
106
111
 
107
112
  def mget(
108
- transaction: TTransaction,
113
+ batch: TBatch,
109
114
  keys: List[TEncodable],
110
115
  path: TEncodable,
111
- ) -> TTransaction:
116
+ ) -> TBatch:
112
117
  """
113
118
  Retrieves the JSON values at the specified `path` stored at multiple `keys`.
114
119
 
115
120
  Note:
116
- When in cluster mode, all keys in the transaction must be mapped to the same slot.
121
+ When in cluster mode:
122
+ - If the batch is an atomic batch (transaction), then all keys must map to the same slot.
123
+ - If the batch is a non-atomic batch (pipeline), and the keys map to different hash slots,
124
+ the command will be split across these slots and executed separately for each.
125
+ This means the command is atomic only at the slot level. If one or more slot-specific
126
+ requests fail, the entire call will return the first encountered error, even
127
+ though some requests may have succeeded while others did not.
128
+ If this behavior impacts your application logic, consider splitting the
129
+ request into sub-requests per slot to ensure atomicity.
117
130
 
118
131
  Args:
119
- transaction (TTransaction): The transaction to execute the command.
132
+ batch (TBatch): The batch to execute the command.
120
133
  keys (List[TEncodable]): A list of keys for the JSON documents.
121
134
  path (TEncodable): The path within the JSON documents.
122
135
 
@@ -131,20 +144,20 @@ def mget(
131
144
  If a key doesn't exist, the corresponding list element will be None.
132
145
  """
133
146
  args = ["JSON.MGET"] + keys + [path]
134
- return transaction.custom_command(args)
147
+ return batch.custom_command(args)
135
148
 
136
149
 
137
150
  def arrappend(
138
- transaction: TTransaction,
151
+ batch: TBatch,
139
152
  key: TEncodable,
140
153
  path: TEncodable,
141
154
  values: List[TEncodable],
142
- ) -> TTransaction:
155
+ ) -> TBatch:
143
156
  """
144
157
  Appends one or more `values` to the JSON array at the specified `path` within the JSON document stored at `key`.
145
158
 
146
159
  Args:
147
- transaction (TTransaction): The transaction to execute the command.
160
+ batch (TBatch): The batch to execute the command.
148
161
  key (TEncodable): The key of the JSON document.
149
162
  path (TEncodable): Represents the path within the JSON document where the `values` will be appended.
150
163
  values (TEncodable): The values to append to the JSON array at the specified path.
@@ -153,8 +166,8 @@ def arrappend(
153
166
  Command response:
154
167
  TJsonResponse[int]:
155
168
  For JSONPath (`path` starts with `$`):
156
- Returns a list of integer replies for every possible path, indicating the new length of the array after appending `values`,
157
- or None for JSON values matching the path that are not an array.
169
+ Returns a list of integer replies for every possible path, indicating the new length of the array after
170
+ appending `values`, or None for JSON values matching the path that are not an array.
158
171
  If `path` doesn't exist, an empty array will be returned.
159
172
  For legacy path (`path` doesn't start with `$`):
160
173
  Returns the length of the array after appending `values` to the array at `path`.
@@ -164,45 +177,49 @@ def arrappend(
164
177
  For more information about the returned type, see `TJsonResponse`.
165
178
  """
166
179
  args = ["JSON.ARRAPPEND", key, path] + values
167
- return transaction.custom_command(args)
180
+ return batch.custom_command(args)
168
181
 
169
182
 
170
183
  def arrindex(
171
- transaction: TTransaction,
184
+ batch: TBatch,
172
185
  key: TEncodable,
173
186
  path: TEncodable,
174
187
  value: TEncodable,
175
188
  options: Optional[JsonArrIndexOptions] = None,
176
- ) -> TTransaction:
189
+ ) -> TBatch:
177
190
  """
178
- Searches for the first occurrence of a scalar JSON value (i.e., a value that is neither an object nor an array) within arrays at the specified `path` in the JSON document stored at `key`.
191
+ Searches for the first occurrence of a scalar JSON value (i.e., a value that is neither an object nor an array) within
192
+ arrays at the specified `path` in the JSON document stored at `key`.
179
193
 
180
194
  If specified, `options.start` and `options.end` define an inclusive-to-exclusive search range within the array.
181
195
  (Where `options.start` is inclusive and `options.end` is exclusive).
182
196
 
183
- Out-of-range indices adjust to the nearest valid position, and negative values count from the end (e.g., `-1` is the last element, `-2` the second last).
197
+ Out-of-range indices adjust to the nearest valid position, and negative values count from the end
198
+ (e.g., `-1` is the last element, `-2` the second last).
184
199
 
185
200
  Setting `options.end` to `0` behaves like `-1`, extending the range to the array's end (inclusive).
186
201
 
187
202
  If `options.start` exceeds `options.end`, `-1` is returned, indicating that the value was not found.
188
203
 
189
204
  Args:
190
- transaction (TTransaction): The transaction to execute the command.
205
+ batch (TBatch): The batch to execute the command.
191
206
  key (TEncodable): The key of the JSON document.
192
207
  path (TEncodable): The path within the JSON document.
193
208
  value (TEncodable): The value to search for within the arrays.
194
- options (Optional[JsonArrIndexOptions]): Options specifying an inclusive `start` index and an optional exclusive `end` index for a range-limited search.
209
+ options (Optional[JsonArrIndexOptions]): Options specifying an inclusive `start` index and an optional exclusive `end`
210
+ index for a range-limited search.
195
211
  Defaults to the full array if not provided. See `JsonArrIndexOptions`.
196
212
 
197
213
  Command response:
198
214
  Optional[Union[int, List[int]]]:
199
215
  For JSONPath (`path` starts with `$`):
200
- Returns an array of integers for every possible path, indicating of the first occurrence of `value` within the array,
201
- or None for JSON values matching the path that are not an array.
216
+ Returns an array of integers for every possible path, indicating of the first occurrence of `value` within the
217
+ array, or None for JSON values matching the path that are not an array.
202
218
  A returned value of `-1` indicates that the value was not found in that particular array.
203
219
  If `path` does not exist, an empty array will be returned.
204
220
  For legacy path (`path` doesn't start with `$`):
205
- Returns an integer representing the index of the first occurrence of `value` within the array at the specified path.
221
+ Returns an integer representing the index of the first occurrence of `value` within the array at the specified
222
+ path.
206
223
  A returned value of `-1` indicates that the value was not found in that particular array.
207
224
  If multiple paths match, the index of the value from the first matching array is returned.
208
225
  If the JSON value at the `path` is not an array or if `path` does not exist, an error is raised.
@@ -213,21 +230,22 @@ def arrindex(
213
230
  if options:
214
231
  args.extend(options.to_args())
215
232
 
216
- return transaction.custom_command(args)
233
+ return batch.custom_command(args)
217
234
 
218
235
 
219
236
  def arrinsert(
220
- transaction: TTransaction,
237
+ batch: TBatch,
221
238
  key: TEncodable,
222
239
  path: TEncodable,
223
240
  index: int,
224
241
  values: List[TEncodable],
225
- ) -> TTransaction:
242
+ ) -> TBatch:
226
243
  """
227
- Inserts one or more values into the array at the specified `path` within the JSON document stored at `key`, before the given `index`.
244
+ Inserts one or more values into the array at the specified `path` within the JSON document stored at `key`, before the
245
+ given `index`.
228
246
 
229
247
  Args:
230
- transaction (TTransaction): The transaction to execute the command.
248
+ batch (TBatch): The batch to execute the command.
231
249
  key (TEncodable): The key of the JSON document.
232
250
  path (TEncodable): The path within the JSON document.
233
251
  index (int): The array index before which values are inserted.
@@ -248,19 +266,19 @@ def arrinsert(
248
266
  If `key` doesn't exist, an error is raised.
249
267
  """
250
268
  args = ["JSON.ARRINSERT", key, path, str(index)] + values
251
- return transaction.custom_command(args)
269
+ return batch.custom_command(args)
252
270
 
253
271
 
254
272
  def arrlen(
255
- transaction: TTransaction,
273
+ batch: TBatch,
256
274
  key: TEncodable,
257
275
  path: Optional[TEncodable] = None,
258
- ) -> TTransaction:
276
+ ) -> TBatch:
259
277
  """
260
278
  Retrieves the length of the array at the specified `path` within the JSON document stored at `key`.
261
279
 
262
280
  Args:
263
- transaction (TTransaction): The transaction to execute the command.
281
+ batch (TBatch): The batch to execute the command.
264
282
  key (TEncodable): The key of the JSON document.
265
283
  path (Optional[TEncodable]): The path within the JSON document. Defaults to None.
266
284
 
@@ -279,22 +297,23 @@ def arrlen(
279
297
  args = ["JSON.ARRLEN", key]
280
298
  if path:
281
299
  args.append(path)
282
- return transaction.custom_command(args)
300
+ return batch.custom_command(args)
283
301
 
284
302
 
285
303
  def arrpop(
286
- transaction: TTransaction,
304
+ batch: TBatch,
287
305
  key: TEncodable,
288
306
  options: Optional[JsonArrPopOptions] = None,
289
- ) -> TTransaction:
307
+ ) -> TBatch:
290
308
  """
291
309
  Pops an element from the array located at the specified path within the JSON document stored at `key`.
292
310
  If `options.index` is provided, it pops the element at that index instead of the last element.
293
311
 
294
312
  Args:
295
- transaction (TTransaction): The transaction to execute the command.
313
+ batch (TBatch): The batch to execute the command.
296
314
  key (TEncodable): The key of the JSON document.
297
- options (Optional[JsonArrPopOptions]): Options including the path and optional index. See `JsonArrPopOptions`. Default to None.
315
+ options (Optional[JsonArrPopOptions]): Options including the path and optional index. See `JsonArrPopOptions`.
316
+ Default to None.
298
317
  If not specified, attempts to pop the last element from the root value if it's an array.
299
318
  If the root value is not an array, an error will be raised.
300
319
 
@@ -314,24 +333,25 @@ def arrpop(
314
333
  if options:
315
334
  args.extend(options.to_args())
316
335
 
317
- return transaction.custom_command(args)
336
+ return batch.custom_command(args)
318
337
 
319
338
 
320
339
  def arrtrim(
321
- transaction: TTransaction,
340
+ batch: TBatch,
322
341
  key: TEncodable,
323
342
  path: TEncodable,
324
343
  start: int,
325
344
  end: int,
326
- ) -> TTransaction:
345
+ ) -> TBatch:
327
346
  """
328
- Trims an array at the specified `path` within the JSON document stored at `key` so that it becomes a subarray [start, end], both inclusive.
347
+ Trims an array at the specified `path` within the JSON document stored at `key` so that it becomes a subarray
348
+ [start, end], both inclusive.
329
349
  If `start` < 0, it is treated as 0.
330
350
  If `end` >= size (size of the array), it is treated as size-1.
331
351
  If `start` >= size or `start` > `end`, the array is emptied and 0 is returned.
332
352
 
333
353
  Args:
334
- transaction (TTransaction): The transaction to execute the command.
354
+ batch (TBatch): The batch to execute the command.
335
355
  key (TEncodable): The key of the JSON document.
336
356
  path (TEncodable): The path within the JSON document.
337
357
  start (int): The start index, inclusive.
@@ -340,7 +360,8 @@ def arrtrim(
340
360
  Command response:
341
361
  TJsonResponse[int]:
342
362
  For JSONPath (`path` starts with '$'):
343
- Returns a list of integer replies for every possible path, indicating the new length of the array, or None for JSON values matching the path that are not an array.
363
+ Returns a list of integer replies for every possible path, indicating the new length of the array, or None for
364
+ JSON values matching the path that are not an array.
344
365
  If a value is an empty array, its corresponding return value is 0.
345
366
  If `path` doesn't exist, an empty array will be returned.
346
367
  For legacy path (`path` doesn't starts with `$`):
@@ -351,45 +372,47 @@ def arrtrim(
351
372
  If `key` doesn't exist, an error is raised.
352
373
  """
353
374
 
354
- return transaction.custom_command(["JSON.ARRTRIM", key, path, str(start), str(end)])
375
+ return batch.custom_command(["JSON.ARRTRIM", key, path, str(start), str(end)])
355
376
 
356
377
 
357
378
  def clear(
358
- transaction: TTransaction,
379
+ batch: TBatch,
359
380
  key: TEncodable,
360
381
  path: Optional[str] = None,
361
- ) -> TTransaction:
382
+ ) -> TBatch:
362
383
  """
363
384
  Clears arrays or objects at the specified JSON path in the document stored at `key`.
364
385
  Numeric values are set to `0`, and boolean values are set to `False`, and string values are converted to empty strings.
365
386
 
366
387
  Args:
367
- transaction (TTransaction): The transaction to execute the command.
388
+ batch (TBatch): The batch to execute the command.
368
389
  key (TEncodable): The key of the JSON document.
369
390
  path (Optional[str]): The path within the JSON document. Default to None.
370
391
 
371
392
  Command response:
372
393
  int: The number of containers cleared, numeric values zeroed, and booleans toggled to `false`,
373
394
  and string values converted to empty strings.
374
- If `path` doesn't exist, or the value at `path` is already empty (e.g., an empty array, object, or string), 0 is returned.
395
+ If `path` doesn't exist, or the value at `path` is already empty (e.g., an empty array, object, or string),
396
+ 0 is returned.
375
397
  If `key doesn't exist, an error is raised.
376
398
  """
377
399
  args = ["JSON.CLEAR", key]
378
400
  if path:
379
401
  args.append(path)
380
402
 
381
- return transaction.custom_command(args)
403
+ return batch.custom_command(args)
382
404
 
383
405
 
384
406
  def debug_fields(
385
- transaction: TTransaction,
407
+ batch: TBatch,
386
408
  key: TEncodable,
387
409
  path: Optional[TEncodable] = None,
388
- ) -> TTransaction:
410
+ ) -> TBatch:
389
411
  """
390
412
  Returns the number of fields of the JSON value at the specified `path` within the JSON document stored at `key`.
391
413
  - **Primitive Values**: Each non-container JSON value (e.g., strings, numbers, booleans, and null) counts as one field.
392
- - **Arrays and Objects:**: Each item in an array and each key-value pair in an object is counted as one field. (Each top-level value counts as one field, regardless of it's type.)
414
+ - **Arrays and Objects:**: Each item in an array and each key-value pair in an object is counted as one field.
415
+ (Each top-level value counts as one field, regardless of it's type.)
393
416
  - Their nested values are counted recursively and added to the total.
394
417
  - **Example**: For the JSON `{"a": 1, "b": [2, 3, {"c": 4}]}`, the count would be:
395
418
  - Top-level: 2 fields (`"a"` and `"b"`)
@@ -397,7 +420,7 @@ def debug_fields(
397
420
  - Total: 2 (top-level) + 3 (from array) + 1 (from nested object) = 6 fields.
398
421
 
399
422
  Args:
400
- transaction (TTransaction): The transaction to execute the command.
423
+ batch (TBatch): The batch to execute the command.
401
424
  key (TEncodable): The key of the JSON document.
402
425
  path (Optional[TEncodable]): The path within the JSON document. Defaults to root if not provided.
403
426
 
@@ -417,19 +440,19 @@ def debug_fields(
417
440
  if path:
418
441
  args.append(path)
419
442
 
420
- return transaction.custom_command(args)
443
+ return batch.custom_command(args)
421
444
 
422
445
 
423
446
  def debug_memory(
424
- transaction: TTransaction,
447
+ batch: TBatch,
425
448
  key: TEncodable,
426
449
  path: Optional[TEncodable] = None,
427
- ) -> TTransaction:
450
+ ) -> TBatch:
428
451
  """
429
452
  Reports memory usage in bytes of a JSON value at the specified `path` within the JSON document stored at `key`.
430
453
 
431
454
  Args:
432
- transaction (TTransaction): The transaction to execute the command.
455
+ batch (TBatch): The batch to execute the command.
433
456
  key (TEncodable): The key of the JSON document.
434
457
  path (Optional[TEncodable]): The path within the JSON document. Defaults to None.
435
458
 
@@ -449,19 +472,19 @@ def debug_memory(
449
472
  if path:
450
473
  args.append(path)
451
474
 
452
- return transaction.custom_command(args)
475
+ return batch.custom_command(args)
453
476
 
454
477
 
455
478
  def delete(
456
- transaction: TTransaction,
479
+ batch: TBatch,
457
480
  key: TEncodable,
458
481
  path: Optional[TEncodable] = None,
459
- ) -> TTransaction:
482
+ ) -> TBatch:
460
483
  """
461
484
  Deletes the JSON value at the specified `path` within the JSON document stored at `key`.
462
485
 
463
486
  Args:
464
- transaction (TTransaction): The transaction to execute the command.
487
+ batch (TBatch): The batch to execute the command.
465
488
  key (TEncodable): The key of the JSON document.
466
489
  path (Optional[TEncodable]): The path within the JSON document.
467
490
  If None, deletes the entire JSON document at `key`. Defaults to None.
@@ -471,19 +494,19 @@ def delete(
471
494
  If `key` or `path` doesn't exist, returns 0.
472
495
  """
473
496
 
474
- return transaction.custom_command(["JSON.DEL", key] + ([path] if path else []))
497
+ return batch.custom_command(["JSON.DEL", key] + ([path] if path else []))
475
498
 
476
499
 
477
500
  def forget(
478
- transaction: TTransaction,
501
+ batch: TBatch,
479
502
  key: TEncodable,
480
503
  path: Optional[TEncodable] = None,
481
- ) -> TTransaction:
504
+ ) -> TBatch:
482
505
  """
483
506
  Deletes the JSON value at the specified `path` within the JSON document stored at `key`.
484
507
 
485
508
  Args:
486
- transaction (TTransaction): The transaction to execute the command.
509
+ batch (TBatch): The batch to execute the command.
487
510
  key (TEncodable): The key of the JSON document.
488
511
  path (Optional[TEncodable]): The path within the JSON document.
489
512
  If None, deletes the entire JSON document at `key`. Defaults to None.
@@ -493,20 +516,20 @@ def forget(
493
516
  If `key` or `path` doesn't exist, returns 0.
494
517
  """
495
518
 
496
- return transaction.custom_command(["JSON.FORGET", key] + ([path] if path else []))
519
+ return batch.custom_command(["JSON.FORGET", key] + ([path] if path else []))
497
520
 
498
521
 
499
522
  def numincrby(
500
- transaction: TTransaction,
523
+ batch: TBatch,
501
524
  key: TEncodable,
502
525
  path: TEncodable,
503
526
  number: Union[int, float],
504
- ) -> TTransaction:
527
+ ) -> TBatch:
505
528
  """
506
529
  Increments or decrements the JSON value(s) at the specified `path` by `number` within the JSON document stored at `key`.
507
530
 
508
531
  Args:
509
- transaction (TTransaction): The transaction to execute the command.
532
+ batch (TBatch): The batch to execute the command.
510
533
  key (TEncodable): The key of the JSON document.
511
534
  path (TEncodable): The path within the JSON document.
512
535
  number (Union[int, float]): The number to increment or decrement by.
@@ -514,7 +537,8 @@ def numincrby(
514
537
  Command response:
515
538
  bytes:
516
539
  For JSONPath (`path` starts with `$`):
517
- Returns a bytes string representation of an array of bulk strings, indicating the new values after incrementing for each matched `path`.
540
+ Returns a bytes string representation of an array of bulk strings, indicating the new values after
541
+ incrementing for each matched `path`.
518
542
  If a value is not a number, its corresponding return value will be `null`.
519
543
  If `path` doesn't exist, a byte string representation of an empty array will be returned.
520
544
  For legacy path (`path` doesn't start with `$`):
@@ -526,20 +550,20 @@ def numincrby(
526
550
  """
527
551
  args = ["JSON.NUMINCRBY", key, path, str(number)]
528
552
 
529
- return transaction.custom_command(args)
553
+ return batch.custom_command(args)
530
554
 
531
555
 
532
556
  def nummultby(
533
- transaction: TTransaction,
557
+ batch: TBatch,
534
558
  key: TEncodable,
535
559
  path: TEncodable,
536
560
  number: Union[int, float],
537
- ) -> TTransaction:
561
+ ) -> TBatch:
538
562
  """
539
563
  Multiplies the JSON value(s) at the specified `path` by `number` within the JSON document stored at `key`.
540
564
 
541
565
  Args:
542
- transaction (TTransaction): The transaction to execute the command.
566
+ batch (TBatch): The batch to execute the command.
543
567
  key (TEncodable): The key of the JSON document.
544
568
  path (TEncodable): The path within the JSON document.
545
569
  number (Union[int, float]): The number to multiply by.
@@ -547,7 +571,8 @@ def nummultby(
547
571
  Command response:
548
572
  bytes:
549
573
  For JSONPath (`path` starts with `$`):
550
- Returns a bytes string representation of an array of bulk strings, indicating the new values after multiplication for each matched `path`.
574
+ Returns a bytes string representation of an array of bulk strings, indicating the new values after
575
+ multiplication for each matched `path`.
551
576
  If a value is not a number, its corresponding return value will be `null`.
552
577
  If `path` doesn't exist, a byte string representation of an empty array will be returned.
553
578
  For legacy path (`path` doesn't start with `$`):
@@ -559,19 +584,20 @@ def nummultby(
559
584
  """
560
585
  args = ["JSON.NUMMULTBY", key, path, str(number)]
561
586
 
562
- return transaction.custom_command(args)
587
+ return batch.custom_command(args)
563
588
 
564
589
 
565
590
  def objlen(
566
- transaction: TTransaction,
591
+ batch: TBatch,
567
592
  key: TEncodable,
568
593
  path: Optional[TEncodable] = None,
569
- ) -> TTransaction:
594
+ ) -> TBatch:
570
595
  """
571
- Retrieves the number of key-value pairs in the object stored at the specified `path` within the JSON document stored at `key`.
596
+ Retrieves the number of key-value pairs in the object stored at the specified `path` within the JSON document stored at
597
+ `key`.
572
598
 
573
599
  Args:
574
- transaction (TTransaction): The transaction to execute the command.
600
+ batch (TBatch): The batch to execute the command.
575
601
  key (TEncodable): The key of the JSON document.
576
602
  path (Optional[TEncodable]): The path within the JSON document. Defaults to None.
577
603
 
@@ -591,19 +617,19 @@ def objlen(
591
617
  if path:
592
618
  args.append(path)
593
619
 
594
- return transaction.custom_command(args)
620
+ return batch.custom_command(args)
595
621
 
596
622
 
597
623
  def objkeys(
598
- transaction: TTransaction,
624
+ batch: TBatch,
599
625
  key: TEncodable,
600
626
  path: Optional[TEncodable] = None,
601
- ) -> TTransaction:
627
+ ) -> TBatch:
602
628
  """
603
629
  Retrieves key names in the object values at the specified `path` within the JSON document stored at `key`.
604
630
 
605
631
  Args:
606
- transaction (TTransaction): The transaction to execute the command.
632
+ batch (TBatch): The batch to execute the command.
607
633
  key (TEncodable): The key of the JSON document.
608
634
  path (Optional[TEncodable]): Represents the path within the JSON document where the key names will be retrieved.
609
635
  Defaults to None.
@@ -625,14 +651,14 @@ def objkeys(
625
651
  if path:
626
652
  args.append(path)
627
653
 
628
- return transaction.custom_command(args)
654
+ return batch.custom_command(args)
629
655
 
630
656
 
631
657
  def resp(
632
- transaction: TTransaction,
658
+ batch: TBatch,
633
659
  key: TEncodable,
634
660
  path: Optional[TEncodable] = None,
635
- ) -> TTransaction:
661
+ ) -> TBatch:
636
662
  """
637
663
  Retrieve the JSON value at the specified `path` within the JSON document stored at `key`.
638
664
  The returning result is in the Valkey or Redis OSS Serialization Protocol (RESP).\n
@@ -641,11 +667,13 @@ def resp(
641
667
  JSON integers are mapped to RESP Integers.\n
642
668
  JSON doubles are mapped to RESP Bulk Strings.\n
643
669
  JSON strings are mapped to RESP Bulk Strings.\n
644
- JSON arrays are represented as RESP arrays, where the first element is the simple string [, followed by the array's elements.\n
645
- JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs, each of which is a RESP bulk string.\n
670
+ JSON arrays are represented as RESP arrays, where the first element is the simple string
671
+ [, followed by the array's elements.\n
672
+ JSON objects are represented as RESP object, where the first element is the simple string {, followed by key-value pairs,
673
+ each of which is a RESP bulk string.\n
646
674
 
647
675
  Args:
648
- transaction (TTransaction): The transaction to execute the command.
676
+ batch (TBatch): The batch to execute the command.
649
677
  key (TEncodable): The key of the JSON document.
650
678
  path (Optional[TEncodable]): The path within the JSON document. Default to None.
651
679
 
@@ -665,28 +693,30 @@ def resp(
665
693
  if path:
666
694
  args.append(path)
667
695
 
668
- return transaction.custom_command(args)
696
+ return batch.custom_command(args)
669
697
 
670
698
 
671
699
  def strappend(
672
- transaction: TTransaction,
700
+ batch: TBatch,
673
701
  key: TEncodable,
674
702
  value: TEncodable,
675
703
  path: Optional[TEncodable] = None,
676
- ) -> TTransaction:
704
+ ) -> TBatch:
677
705
  """
678
706
  Appends the specified `value` to the string stored at the specified `path` within the JSON document stored at `key`.
679
707
 
680
708
  Args:
681
- transaction (TTransaction): The transaction to execute the command.
709
+ batch (TBatch): The batch to execute the command.
682
710
  key (TEncodable): The key of the JSON document.
683
- value (TEncodable): The value to append to the string. Must be wrapped with single quotes. For example, to append "foo", pass '"foo"'.
711
+ value (TEncodable): The value to append to the string. Must be wrapped with single quotes. For example,
712
+ to append "foo", pass '"foo"'.
684
713
  path (Optional[TEncodable]): The path within the JSON document. Default to None.
685
714
 
686
715
  Command response:
687
716
  TJsonResponse[int]:
688
717
  For JSONPath (`path` starts with `$`):
689
- Returns a list of integer replies for every possible path, indicating the length of the resulting string after appending `value`,
718
+ Returns a list of integer replies for every possible path, indicating the length of the resulting string after
719
+ appending `value`,
690
720
  or None for JSON values matching the path that are not string.
691
721
  If `key` doesn't exist, an error is raised.
692
722
  For legacy path (`path` doesn't start with `$`):
@@ -696,21 +726,21 @@ def strappend(
696
726
  If `key` doesn't exist, an error is raised.
697
727
  For more information about the returned type, see `TJsonResponse`.
698
728
  """
699
- return transaction.custom_command(
729
+ return batch.custom_command(
700
730
  ["JSON.STRAPPEND", key] + ([path, value] if path else [value])
701
731
  )
702
732
 
703
733
 
704
734
  def strlen(
705
- transaction: TTransaction,
735
+ batch: TBatch,
706
736
  key: TEncodable,
707
737
  path: Optional[TEncodable] = None,
708
- ) -> TTransaction:
738
+ ) -> TBatch:
709
739
  """
710
740
  Returns the length of the JSON string value stored at the specified `path` within the JSON document stored at `key`.
711
741
 
712
742
  Args:
713
- transaction (TTransaction): The transaction to execute the command.
743
+ batch (TBatch): The batch to execute the command.
714
744
  key (TEncodable): The key of the JSON document.
715
745
  path (Optional[TEncodable]): The path within the JSON document. Default to None.
716
746
 
@@ -726,21 +756,21 @@ def strlen(
726
756
  If `key` doesn't exist, None is returned.
727
757
  For more information about the returned type, see `TJsonResponse`.
728
758
  """
729
- return transaction.custom_command(
759
+ return batch.custom_command(
730
760
  ["JSON.STRLEN", key, path] if path else ["JSON.STRLEN", key]
731
761
  )
732
762
 
733
763
 
734
764
  def toggle(
735
- transaction: TTransaction,
765
+ batch: TBatch,
736
766
  key: TEncodable,
737
767
  path: TEncodable,
738
- ) -> TTransaction:
768
+ ) -> TBatch:
739
769
  """
740
770
  Toggles a Boolean value stored at the specified `path` within the JSON document stored at `key`.
741
771
 
742
772
  Args:
743
- transaction (TTransaction): The transaction to execute the command.
773
+ batch (TBatch): The batch to execute the command.
744
774
  key (TEncodable): The key of the JSON document.
745
775
  path (TEncodable): The path within the JSON document. Default to None.
746
776
 
@@ -756,19 +786,19 @@ def toggle(
756
786
  If `key` doesn't exist, an error is raised.
757
787
  For more information about the returned type, see `TJsonResponse`.
758
788
  """
759
- return transaction.custom_command(["JSON.TOGGLE", key, path])
789
+ return batch.custom_command(["JSON.TOGGLE", key, path])
760
790
 
761
791
 
762
792
  def type(
763
- transaction: TTransaction,
793
+ batch: TBatch,
764
794
  key: TEncodable,
765
795
  path: Optional[TEncodable] = None,
766
- ) -> TTransaction:
796
+ ) -> TBatch:
767
797
  """
768
798
  Retrieves the type of the JSON value at the specified `path` within the JSON document stored at `key`.
769
799
 
770
800
  Args:
771
- transaction (TTransaction): The transaction to execute the command.
801
+ batch (TBatch): The batch to execute the command.
772
802
  key (TEncodable): The key of the JSON document.
773
803
  path (Optional[TEncodable]): The path within the JSON document. Default to None.
774
804
 
@@ -787,4 +817,4 @@ def type(
787
817
  if path:
788
818
  args.append(path)
789
819
 
790
- return transaction.custom_command(args)
820
+ return batch.custom_command(args)