valkey-glide 2.0.0rc2__cp312-cp312-macosx_11_0_arm64.whl → 2.2.0rc2__cp312-cp312-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. glide/__init__.py +160 -106
  2. glide/async_commands/cluster_commands.py +108 -105
  3. glide/async_commands/core.py +637 -444
  4. glide/async_commands/{server_modules/ft.py → ft.py} +8 -7
  5. glide/async_commands/{server_modules/glide_json.py → glide_json.py} +15 -92
  6. glide/async_commands/standalone_commands.py +27 -58
  7. glide/glide.cpython-312-darwin.so +0 -0
  8. glide/glide.pyi +26 -1
  9. glide/glide_client.py +270 -126
  10. glide/logger.py +33 -21
  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 → glide_shared/commands}/batch.py +476 -64
  15. glide_shared/commands/batch_options.py +261 -0
  16. glide_shared/commands/core_options.py +407 -0
  17. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_aggregate_options.py +3 -3
  18. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_create_options.py +4 -2
  19. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_profile_options.py +4 -4
  20. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_search_options.py +4 -2
  21. {glide/async_commands → glide_shared/commands}/server_modules/json_batch.py +4 -4
  22. glide_shared/commands/server_modules/json_options.py +93 -0
  23. {glide/async_commands → glide_shared/commands}/sorted_set.py +2 -2
  24. {glide/async_commands → glide_shared/commands}/stream.py +1 -1
  25. {glide → glide_shared}/config.py +386 -61
  26. {glide → glide_shared}/constants.py +3 -3
  27. {glide → glide_shared}/exceptions.py +27 -1
  28. glide_shared/protobuf/command_request_pb2.py +56 -0
  29. glide_shared/protobuf/connection_request_pb2.py +56 -0
  30. {glide → glide_shared}/protobuf/response_pb2.py +6 -6
  31. {glide → glide_shared}/routes.py +54 -15
  32. valkey_glide-2.2.0rc2.dist-info/METADATA +210 -0
  33. valkey_glide-2.2.0rc2.dist-info/RECORD +40 -0
  34. glide/protobuf/command_request_pb2.py +0 -54
  35. glide/protobuf/command_request_pb2.pyi +0 -1187
  36. glide/protobuf/connection_request_pb2.py +0 -54
  37. glide/protobuf/connection_request_pb2.pyi +0 -320
  38. glide/protobuf/response_pb2.pyi +0 -100
  39. valkey_glide-2.0.0rc2.dist-info/METADATA +0 -127
  40. valkey_glide-2.0.0rc2.dist-info/RECORD +0 -37
  41. {glide/async_commands → glide_shared/commands}/bitmap.py +0 -0
  42. {glide/async_commands → glide_shared/commands}/command_args.py +0 -0
  43. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
  44. {glide → glide_shared}/protobuf_codec.py +0 -0
  45. {valkey_glide-2.0.0rc2.dist-info → valkey_glide-2.2.0rc2.dist-info}/WHEEL +0 -0
@@ -1,10 +1,10 @@
1
1
  # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
2
 
3
+ import sys
3
4
  import threading
4
5
  from typing import List, Mapping, Optional, Tuple, TypeVar, Union
5
6
 
6
- from deprecated import deprecated
7
- from glide.async_commands.bitmap import (
7
+ from glide_shared.commands.bitmap import (
8
8
  BitFieldGet,
9
9
  BitFieldSubCommands,
10
10
  BitwiseOperation,
@@ -12,26 +12,27 @@ from glide.async_commands.bitmap import (
12
12
  _create_bitfield_args,
13
13
  _create_bitfield_read_only_args,
14
14
  )
15
- from glide.async_commands.command_args import Limit, ListDirection, OrderBy
16
- from glide.async_commands.core import (
15
+ from glide_shared.commands.command_args import Limit, ListDirection, OrderBy
16
+ from glide_shared.commands.core_options import (
17
17
  ConditionalChange,
18
18
  ExpireOptions,
19
19
  ExpiryGetEx,
20
20
  ExpirySet,
21
21
  FlushMode,
22
22
  FunctionRestorePolicy,
23
- GeospatialData,
24
- GeoUnit,
23
+ HashFieldConditionalChange,
25
24
  InfoSection,
26
25
  InsertPosition,
27
26
  UpdateOptions,
28
27
  _build_sort_args,
29
28
  )
30
- from glide.async_commands.sorted_set import (
29
+ from glide_shared.commands.sorted_set import (
31
30
  AggregationType,
32
31
  GeoSearchByBox,
33
32
  GeoSearchByRadius,
34
33
  GeoSearchCount,
34
+ GeospatialData,
35
+ GeoUnit,
35
36
  InfBound,
36
37
  LexBoundary,
37
38
  RangeByIndex,
@@ -43,7 +44,7 @@ from glide.async_commands.sorted_set import (
43
44
  _create_zinter_zunion_cmd_args,
44
45
  _create_zrange_args,
45
46
  )
46
- from glide.async_commands.stream import (
47
+ from glide_shared.commands.stream import (
47
48
  StreamAddOptions,
48
49
  StreamClaimOptions,
49
50
  StreamGroupOptions,
@@ -54,8 +55,14 @@ from glide.async_commands.stream import (
54
55
  StreamTrimOptions,
55
56
  _create_xpending_range_args,
56
57
  )
57
- from glide.constants import TEncodable
58
- from glide.protobuf.command_request_pb2 import RequestType
58
+ from glide_shared.constants import TEncodable
59
+ from glide_shared.exceptions import RequestError
60
+ from glide_shared.protobuf.command_request_pb2 import RequestType
61
+
62
+ if sys.version_info >= (3, 13):
63
+ from warnings import deprecated
64
+ else:
65
+ from typing_extensions import deprecated
59
66
 
60
67
  TBatch = TypeVar("TBatch", bound="BaseBatch")
61
68
 
@@ -109,7 +116,7 @@ class BaseBatch:
109
116
 
110
117
  def get(self: TBatch, key: TEncodable) -> TBatch:
111
118
  """
112
- Get the value associated with the given key, or null if no such value exists.
119
+ Get the value associated with the given key, or null if no such key exists.
113
120
 
114
121
  See [valkey.io](https://valkey.io/commands/get/) for details.
115
122
 
@@ -273,6 +280,10 @@ class BaseBatch:
273
280
  [custom command](https://github.com/valkey-io/valkey-glide/wiki/General-Concepts#custom-command)
274
281
  for details on the restrictions and limitations of the custom command API.
275
282
 
283
+ This function should only be used for single-response commands. Commands that don't return complete response and awaits
284
+ (such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the
285
+ client's behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
286
+
276
287
  Args:
277
288
  command_args (List[TEncodable]): List of command arguments.
278
289
  Every part of the command, including the command name and subcommands, should be added as a
@@ -312,6 +323,8 @@ class BaseBatch:
312
323
  """
313
324
  Get information and statistics about the server.
314
325
 
326
+ Starting from server version 7, command supports multiple section arguments.
327
+
315
328
  See [valkey.io](https://valkey.io/commands/info/) for details.
316
329
 
317
330
  Args:
@@ -390,6 +403,27 @@ class BaseBatch:
390
403
  """
391
404
  return self.append_command(RequestType.ConfigResetStat, [])
392
405
 
406
+ def move(self: TBatch, key: TEncodable, db_index: int) -> "TBatch":
407
+ """
408
+ Move `key` from the currently selected database to the database specified by `db_index`.
409
+
410
+ Note:
411
+ For cluster mode move command is supported since Valkey 9.0.0
412
+
413
+ See [valkey.io](https://valkey.io/commands/move/) for more details.
414
+
415
+ Args:
416
+ key (TEncodable): The key to move.
417
+ db_index (int): The index of the database to move `key` to.
418
+
419
+ Commands response:
420
+ bool: True if `key` was moved.
421
+
422
+ False if the `key` already exists in the destination database
423
+ or does not exist in the source database.
424
+ """
425
+ return self.append_command(RequestType.Move, [key, str(db_index)])
426
+
393
427
  def mset(self: TBatch, key_value_map: Mapping[TEncodable, TEncodable]) -> TBatch:
394
428
  """
395
429
  Set multiple keys to multiple values in a single atomic operation.
@@ -944,6 +978,391 @@ class BaseBatch:
944
978
  """
945
979
  return self.append_command(RequestType.HStrlen, [key, field])
946
980
 
981
+ def httl(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
982
+ """
983
+ Returns the remaining time to live (in seconds) of hash key's field(s) that have an associated expiration.
984
+
985
+ See [valkey.io](https://valkey.io/commands/httl/) for more details.
986
+
987
+ Args:
988
+ key (TEncodable): The key of the hash.
989
+ fields (List[TEncodable]): The list of fields to get TTL for.
990
+
991
+ Commands response:
992
+ List[int]: A list of TTL values for each field:
993
+ - Positive integer: remaining TTL in seconds
994
+ - `-1`: field exists but has no expiration
995
+ - `-2`: field does not exist or key does not exist
996
+
997
+ Since: Valkey 9.0.0
998
+ """
999
+ return self.append_command(
1000
+ RequestType.HTtl, [key, "FIELDS", str(len(fields))] + fields
1001
+ )
1002
+
1003
+ def hpttl(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
1004
+ """
1005
+ Returns the remaining time to live (in milliseconds) of hash key's field(s) that have an associated expiration.
1006
+
1007
+ See [valkey.io](https://valkey.io/commands/hpttl/) for more details.
1008
+
1009
+ Args:
1010
+ key (TEncodable): The key of the hash.
1011
+ fields (List[TEncodable]): The list of fields to get TTL for.
1012
+
1013
+ Commands response:
1014
+ List[int]: A list of TTL values for each field:
1015
+ - Positive integer: remaining TTL in milliseconds
1016
+ - `-1`: field exists but has no expiration
1017
+ - `-2`: field does not exist or key does not exist
1018
+
1019
+ Since: Valkey 9.0.0
1020
+ """
1021
+ return self.append_command(
1022
+ RequestType.HPTtl, [key, "FIELDS", str(len(fields))] + fields
1023
+ )
1024
+
1025
+ def hexpiretime(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
1026
+ """
1027
+ Returns the expiration Unix timestamp (in seconds) of hash key's field(s) that have an associated expiration.
1028
+
1029
+ See [valkey.io](https://valkey.io/commands/hexpiretime/) for more details.
1030
+
1031
+ Args:
1032
+ key (TEncodable): The key of the hash.
1033
+ fields (List[TEncodable]): The list of fields to get expiration timestamps for.
1034
+
1035
+ Commands response:
1036
+ List[int]: A list of expiration timestamps for each field:
1037
+ - Positive integer: absolute expiration timestamp in seconds (Unix timestamp)
1038
+ - `-1`: field exists but has no expiration
1039
+ - `-2`: field does not exist or key does not exist
1040
+
1041
+ Since: Valkey 9.0.0
1042
+ """
1043
+ return self.append_command(
1044
+ RequestType.HExpireTime, [key, "FIELDS", str(len(fields))] + fields
1045
+ )
1046
+
1047
+ def hpexpiretime(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
1048
+ """
1049
+ Returns the expiration Unix timestamp (in milliseconds) of hash key's field(s) that have an associated expiration.
1050
+
1051
+ See [valkey.io](https://valkey.io/commands/hpexpiretime/) for more details.
1052
+
1053
+ Args:
1054
+ key (TEncodable): The key of the hash.
1055
+ fields (List[TEncodable]): The list of fields to get expiration timestamps for.
1056
+
1057
+ Returns:
1058
+ TBatch: The batch object for method chaining.
1059
+
1060
+ Command Response:
1061
+ List[int]: A list of expiration timestamps for each field:
1062
+ - Positive integer: absolute expiration timestamp in milliseconds (Unix timestamp in ms)
1063
+ - `-1`: field exists but has no expiration
1064
+ - `-2`: field does not exist or key does not exist
1065
+
1066
+ Since: Valkey 9.0.0
1067
+ """
1068
+ return self.append_command(
1069
+ RequestType.HPExpireTime, [key, "FIELDS", str(len(fields))] + fields
1070
+ )
1071
+
1072
+ def hsetex(
1073
+ self: TBatch,
1074
+ key: TEncodable,
1075
+ field_value_map: Mapping[TEncodable, TEncodable],
1076
+ field_conditional_change: Optional[HashFieldConditionalChange] = None,
1077
+ expiry: Optional[ExpirySet] = None,
1078
+ ) -> TBatch:
1079
+ """
1080
+ Sets the specified fields to their respective values in the hash stored at `key` with optional expiration.
1081
+
1082
+ See [valkey.io](https://valkey.io/commands/hsetex/) for more details.
1083
+
1084
+ Args:
1085
+ key (TEncodable): The key of the hash.
1086
+ field_value_map (Mapping[TEncodable, TEncodable]): A field-value map consisting of fields and their corresponding
1087
+ values to be set in the hash stored at the specified key.
1088
+ field_conditional_change (Optional[HashFieldConditionalChange]): Field conditional change option:
1089
+ - ONLY_IF_ALL_EXIST (FXX): Only set fields if all of them already exist.
1090
+ - ONLY_IF_NONE_EXIST (FNX): Only set fields if none of them already exist.
1091
+ expiry (Optional[ExpirySet]): Expiration options for the fields:
1092
+ - EX: Expiration time in seconds.
1093
+ - PX: Expiration time in milliseconds.
1094
+ - EXAT: Absolute expiration time in seconds (Unix timestamp).
1095
+ - PXAT: Absolute expiration time in milliseconds (Unix timestamp).
1096
+ - KEEPTTL: Retain existing TTL.
1097
+
1098
+ Commands response:
1099
+ int: 1 if all fields were set successfully, 0 if none were set due to conditional constraints.
1100
+
1101
+ Since: Valkey 9.0.0
1102
+ """
1103
+ args: List[TEncodable] = [key]
1104
+
1105
+ # Add field conditional change option if specified
1106
+ if field_conditional_change is not None:
1107
+ args.append(field_conditional_change.value)
1108
+
1109
+ # Add expiry options if specified
1110
+ if expiry is not None:
1111
+ args.extend(expiry.get_cmd_args())
1112
+
1113
+ # Add FIELDS keyword and field count
1114
+ args.extend(["FIELDS", str(len(field_value_map))])
1115
+
1116
+ # Add field-value pairs
1117
+ for field, value in field_value_map.items():
1118
+ args.extend([field, value])
1119
+
1120
+ return self.append_command(RequestType.HSetEx, args)
1121
+
1122
+ def hgetex(
1123
+ self: TBatch,
1124
+ key: TEncodable,
1125
+ fields: List[TEncodable],
1126
+ expiry: Optional[ExpiryGetEx] = None,
1127
+ ) -> TBatch:
1128
+ """
1129
+ Retrieves the values of specified fields in the hash stored at `key` and optionally sets their expiration.
1130
+
1131
+ See [valkey.io](https://valkey.io/commands/hgetex/) for more details.
1132
+
1133
+ Args:
1134
+ key (TEncodable): The key of the hash.
1135
+ fields (List[TEncodable]): The list of fields to retrieve from the hash.
1136
+ expiry (Optional[ExpiryGetEx]): Expiration options for the retrieved fields:
1137
+ - EX: Expiration time in seconds.
1138
+ - PX: Expiration time in milliseconds.
1139
+ - EXAT: Absolute expiration time in seconds (Unix timestamp).
1140
+ - PXAT: Absolute expiration time in milliseconds (Unix timestamp).
1141
+ - PERSIST: Remove expiration from the fields.
1142
+
1143
+ Commands response:
1144
+ Optional[List[Optional[bytes]]]: A list of values associated with the given fields, in the same order as requested.
1145
+ For every field that does not exist in the hash, a null value is returned.
1146
+ If `key` does not exist, it is treated as an empty hash, and the function returns a list of null values.
1147
+
1148
+ Since: Valkey 9.0.0
1149
+ """
1150
+ args: List[TEncodable] = [key]
1151
+
1152
+ # Add expiry options if specified
1153
+ if expiry is not None:
1154
+ args.extend(expiry.get_cmd_args())
1155
+
1156
+ # Add FIELDS keyword and field count
1157
+ args.extend(["FIELDS", str(len(fields))])
1158
+
1159
+ # Add fields
1160
+ args.extend(fields)
1161
+
1162
+ return self.append_command(RequestType.HGetEx, args)
1163
+
1164
+ def hexpire(
1165
+ self: TBatch,
1166
+ key: TEncodable,
1167
+ seconds: int,
1168
+ fields: List[TEncodable],
1169
+ option: Optional[ExpireOptions] = None,
1170
+ ) -> TBatch:
1171
+ """
1172
+ Sets expiration time in seconds for one or more hash fields.
1173
+
1174
+ See [valkey.io](https://valkey.io/commands/hexpire/) for more details.
1175
+
1176
+ Args:
1177
+ key (TEncodable): The key of the hash.
1178
+ seconds (int): The expiration time in seconds.
1179
+ fields (List[TEncodable]): The list of fields to set expiration for.
1180
+ option (Optional[ExpireOptions]): Conditional expiration option:
1181
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1182
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1183
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1184
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1185
+
1186
+ Commands response:
1187
+ List[int]: A list of status codes for each field:
1188
+ - `1`: Expiration time was applied successfully.
1189
+ - `0`: Specified condition was not met.
1190
+ - `-2`: Field does not exist or key does not exist.
1191
+ - `2`: Field was deleted immediately (when seconds is 0 or timestamp is in the past).
1192
+
1193
+ Since: Valkey 9.0.0
1194
+ """
1195
+ args: List[TEncodable] = [key, str(seconds)]
1196
+
1197
+ # Add conditional option if specified
1198
+ if option is not None:
1199
+ args.append(option.value)
1200
+
1201
+ # Add FIELDS keyword and field count
1202
+ args.extend(["FIELDS", str(len(fields))])
1203
+
1204
+ # Add fields
1205
+ args.extend(fields)
1206
+
1207
+ return self.append_command(RequestType.HExpire, args)
1208
+
1209
+ def hpersist(self: TBatch, key: TEncodable, fields: List[TEncodable]) -> TBatch:
1210
+ """
1211
+ Removes the expiration from one or more hash fields, making them persistent.
1212
+
1213
+ See [valkey.io](https://valkey.io/commands/hpersist/) for more details.
1214
+
1215
+ Args:
1216
+ key (TEncodable): The key of the hash.
1217
+ fields (List[TEncodable]): The list of fields to remove expiration from.
1218
+
1219
+ Commands response:
1220
+ List[int]: A list of status codes for each field:
1221
+ - `1`: Expiration was removed successfully (field became persistent).
1222
+ - `-1`: Field exists but has no expiration.
1223
+ - `-2`: Field does not exist or key does not exist.
1224
+
1225
+ Since: Valkey 9.0.0
1226
+ """
1227
+ args: List[TEncodable] = [key, "FIELDS", str(len(fields))] + fields
1228
+
1229
+ return self.append_command(RequestType.HPersist, args)
1230
+
1231
+ def hpexpire(
1232
+ self: TBatch,
1233
+ key: TEncodable,
1234
+ milliseconds: int,
1235
+ fields: List[TEncodable],
1236
+ option: Optional[ExpireOptions] = None,
1237
+ ) -> TBatch:
1238
+ """
1239
+ Sets expiration time in milliseconds for one or more hash fields.
1240
+
1241
+ See [valkey.io](https://valkey.io/commands/hpexpire/) for more details.
1242
+
1243
+ Args:
1244
+ key (TEncodable): The key of the hash.
1245
+ milliseconds (int): The expiration time in milliseconds.
1246
+ fields (List[TEncodable]): The list of fields to set expiration for.
1247
+ option (Optional[ExpireOptions]): Conditional expiration option:
1248
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1249
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1250
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1251
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1252
+
1253
+ Commands response:
1254
+ List[int]: A list of status codes for each field:
1255
+ - `1`: Expiration time was applied successfully.
1256
+ - `0`: Specified condition was not met.
1257
+ - `-2`: Field does not exist or key does not exist.
1258
+ - `2`: Field was deleted immediately (when milliseconds is 0 or timestamp is in the past).
1259
+
1260
+ Since: Valkey 9.0.0
1261
+ """
1262
+ args: List[TEncodable] = [key, str(milliseconds)]
1263
+
1264
+ # Add conditional option if specified
1265
+ if option is not None:
1266
+ args.append(option.value)
1267
+
1268
+ # Add FIELDS keyword and field count
1269
+ args.extend(["FIELDS", str(len(fields))])
1270
+
1271
+ # Add fields
1272
+ args.extend(fields)
1273
+
1274
+ return self.append_command(RequestType.HPExpire, args)
1275
+
1276
+ def hexpireat(
1277
+ self: TBatch,
1278
+ key: TEncodable,
1279
+ unix_timestamp: int,
1280
+ fields: List[TEncodable],
1281
+ option: Optional[ExpireOptions] = None,
1282
+ ) -> TBatch:
1283
+ """
1284
+ Sets expiration time at absolute Unix timestamp in seconds for one or more hash fields.
1285
+
1286
+ See [valkey.io](https://valkey.io/commands/hexpireat/) for more details.
1287
+
1288
+ Args:
1289
+ key (TEncodable): The key of the hash.
1290
+ unix_timestamp (int): The absolute expiration time as Unix timestamp in seconds.
1291
+ fields (List[TEncodable]): The list of fields to set expiration for.
1292
+ option (Optional[ExpireOptions]): Conditional expiration option:
1293
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1294
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1295
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1296
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1297
+
1298
+ Commands response:
1299
+ List[int]: A list of status codes for each field:
1300
+ - `1`: Expiration time was applied successfully.
1301
+ - `0`: Specified condition was not met.
1302
+ - `-2`: Field does not exist or key does not exist.
1303
+ - `2`: Field was deleted immediately (when timestamp is in the past).
1304
+
1305
+ Since: Valkey 9.0.0
1306
+ """
1307
+ args: List[TEncodable] = [key, str(unix_timestamp)]
1308
+
1309
+ # Add conditional option if specified
1310
+ if option is not None:
1311
+ args.append(option.value)
1312
+
1313
+ # Add FIELDS keyword and field count
1314
+ args.extend(["FIELDS", str(len(fields))])
1315
+
1316
+ # Add fields
1317
+ args.extend(fields)
1318
+
1319
+ return self.append_command(RequestType.HExpireAt, args)
1320
+
1321
+ def hpexpireat(
1322
+ self: TBatch,
1323
+ key: TEncodable,
1324
+ unix_timestamp_ms: int,
1325
+ fields: List[TEncodable],
1326
+ option: Optional[ExpireOptions] = None,
1327
+ ) -> TBatch:
1328
+ """
1329
+ Sets expiration time at absolute Unix timestamp in milliseconds for one or more hash fields.
1330
+
1331
+ See [valkey.io](https://valkey.io/commands/hpexpireat/) for more details.
1332
+
1333
+ Args:
1334
+ key (TEncodable): The key of the hash.
1335
+ unix_timestamp_ms (int): The absolute expiration time as Unix timestamp in milliseconds.
1336
+ fields (List[TEncodable]): The list of fields to set expiration for.
1337
+ option (Optional[ExpireOptions]): Conditional expiration option:
1338
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1339
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1340
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1341
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1342
+
1343
+ Commands response:
1344
+ List[int]: A list of status codes for each field:
1345
+ - `1`: Expiration time was applied successfully.
1346
+ - `0`: Specified condition was not met.
1347
+ - `-2`: Field does not exist or key does not exist.
1348
+ - `2`: Field was deleted immediately (when timestamp is in the past).
1349
+
1350
+ Since: Valkey 9.0.0
1351
+ """
1352
+ args: List[TEncodable] = [key, str(unix_timestamp_ms)]
1353
+
1354
+ # Add conditional option if specified
1355
+ if option is not None:
1356
+ args.append(option.value)
1357
+
1358
+ # Add FIELDS keyword and field count
1359
+ args.extend(["FIELDS", str(len(fields))])
1360
+
1361
+ # Add fields
1362
+ args.extend(fields)
1363
+
1364
+ return self.append_command(RequestType.HPExpireAt, args)
1365
+
947
1366
  def lpush(self: TBatch, key: TEncodable, elements: List[TEncodable]) -> TBatch:
948
1367
  """
949
1368
  Insert all the specified values at the head of the list stored at `key`.
@@ -1057,7 +1476,7 @@ class BaseBatch:
1057
1476
  Command response:
1058
1477
  Optional[Mapping[bytes, List[bytes]]]: A map of `key` name mapped to an array of popped elements.
1059
1478
 
1060
- None if no elements could be popped.
1479
+ `None` if no elements could be popped.
1061
1480
 
1062
1481
  Since: Valkey version 7.0.0.
1063
1482
  """
@@ -1683,8 +2102,8 @@ class BaseBatch:
1683
2102
  Commands response:
1684
2103
  TOK: A simple "OK" response.
1685
2104
 
1686
- If `start` exceeds the end of the list, or if `start` is greater than `end`, the result will be an empty list
1687
- (which causes `key` to be removed).
2105
+ If `start` exceeds the end of the list, or if `start` is greater than `end`, the list is emptied
2106
+ and the key is removed.
1688
2107
 
1689
2108
  If `end` exceeds the actual end of the list, it will be treated like the last element of the list.
1690
2109
 
@@ -1700,16 +2119,18 @@ class BaseBatch:
1700
2119
  ) -> TBatch:
1701
2120
  """
1702
2121
  Removes the first `count` occurrences of elements equal to `element` from the list stored at `key`.
1703
- If `count` is positive, it removes elements equal to `element` moving from head to tail.
1704
- If `count` is negative, it removes elements equal to `element` moving from tail to head.
1705
- If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
1706
- equal to `element`.
1707
2122
 
1708
2123
  See [valkey.io](https://valkey.io/commands/lrem/) for more details.
1709
2124
 
1710
2125
  Args:
1711
2126
  key (TEncodable): The key of the list.
1712
2127
  count (int): The count of occurrences of elements equal to `element` to remove.
2128
+
2129
+ - If `count` is positive, it removes elements equal to `element` moving from head to tail.
2130
+ - If `count` is negative, it removes elements equal to `element` moving from tail to head.
2131
+ - If `count` is 0 or greater than the occurrences of elements equal to `element`, it removes all elements
2132
+ equal to `element`.
2133
+
1713
2134
  element (TEncodable): The element to remove from the list.
1714
2135
 
1715
2136
  Commands response:
@@ -2306,6 +2727,10 @@ class BaseBatch:
2306
2727
  args.append("REPLACE")
2307
2728
  if absttl is True:
2308
2729
  args.append("ABSTTL")
2730
+ if idletime is not None and frequency is not None:
2731
+ raise RequestError(
2732
+ "syntax error: IDLETIME and FREQ cannot be set at the same time."
2733
+ )
2309
2734
  if idletime is not None:
2310
2735
  args.extend(["IDLETIME", str(idletime)])
2311
2736
  if frequency is not None:
@@ -2412,26 +2837,26 @@ class BaseBatch:
2412
2837
 
2413
2838
  Args:
2414
2839
  key (TEncodable): The key of the stream.
2415
- start (StreamRangeBound): The starting stream ID bound for the range.
2840
+ start (StreamRangeBound): The starting stream entry ID bound for the range.
2416
2841
 
2417
- - Use `IdBound` to specify a stream ID.
2418
- - Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
2842
+ - Use `IdBound` to specify a stream entry ID.
2843
+ - Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
2419
2844
  - Use `MinId` to start with the minimum available ID.
2420
2845
 
2421
- end (StreamRangeBound): The ending stream ID bound for the range.
2846
+ end (StreamRangeBound): The ending stream entry ID bound for the range.
2422
2847
 
2423
- - Use `IdBound` to specify a stream ID.
2424
- - Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
2848
+ - Use `IdBound` to specify a stream entry ID.
2849
+ - Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
2425
2850
  - Use `MaxId` to end with the maximum available ID.
2426
2851
 
2427
2852
  count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
2428
2853
  If `count` is not provided, all stream entries in the range will be returned.
2429
2854
 
2430
2855
  Command response:
2431
- Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
2856
+ Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream entry IDs to stream entry data, where entry data is a
2432
2857
  list of pairings with format `[[field, entry], [field, entry], ...]`.
2433
2858
 
2434
- Returns None if the range arguments are not applicable.
2859
+ Returns None if the range arguments are not applicable. Or if count is non-positive.
2435
2860
  """
2436
2861
  args = [key, start.to_arg(), end.to_arg()]
2437
2862
  if count is not None:
@@ -2454,26 +2879,26 @@ class BaseBatch:
2454
2879
 
2455
2880
  Args:
2456
2881
  key (TEncodable): The key of the stream.
2457
- end (StreamRangeBound): The ending stream ID bound for the range.
2882
+ end (StreamRangeBound): The ending stream entry ID bound for the range.
2458
2883
 
2459
- - Use `IdBound` to specify a stream ID.
2460
- - Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
2884
+ - Use `IdBound` to specify a stream entry ID.
2885
+ - Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
2461
2886
  - Use `MaxId` to end with the maximum available ID.
2462
2887
 
2463
- start (StreamRangeBound): The starting stream ID bound for the range.
2888
+ start (StreamRangeBound): The starting stream entry ID bound for the range.
2464
2889
 
2465
- - Use `IdBound` to specify a stream ID.
2466
- - Use `ExclusiveIdBound` to specify an exclusive bounded stream ID.
2890
+ - Use `IdBound` to specify a stream entry ID.
2891
+ - Since Valkey 6.2.0, use `ExclusiveIdBound` to specify an exclusive bounded stream entry ID.
2467
2892
  - Use `MinId` to start with the minimum available ID.
2468
2893
 
2469
2894
  count (Optional[int]): An optional argument specifying the maximum count of stream entries to return.
2470
2895
  If `count` is not provided, all stream entries in the range will be returned.
2471
2896
 
2472
2897
  Command response:
2473
- Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream IDs to stream entry data, where entry data is a
2898
+ Optional[Mapping[bytes, List[List[bytes]]]]: A mapping of stream entry IDs to stream entry data, where entry data is a
2474
2899
  list of pairings with format `[[field, entry], [field, entry], ...]`.
2475
2900
 
2476
- Returns None if the range arguments are not applicable.
2901
+ Returns None if the range arguments are not applicable. Or if count is non-positive.
2477
2902
  """
2478
2903
  args = [key, end.to_arg(), start.to_arg()]
2479
2904
  if count is not None:
@@ -2787,7 +3212,7 @@ class BaseBatch:
2787
3212
  min_idle_time_ms (int): Filters the claimed entries to those that have been idle for more than the specified
2788
3213
  value.
2789
3214
  start (TEncodable): Filters the claimed entries to those that have an ID equal or greater than the specified value.
2790
- count (Optional[int]): Limits the number of claimed entries to the specified value.
3215
+ count (Optional[int]): Limits the number of claimed entries to the specified value. Default value is 100.
2791
3216
 
2792
3217
  Command response:
2793
3218
  List[Union[str, Mapping[bytes, List[List[bytes]]], List[bytes]]]: A list containing the following elements:
@@ -2832,7 +3257,7 @@ class BaseBatch:
2832
3257
  min_idle_time_ms (int): Filters the claimed entries to those that have been idle for more than the specified
2833
3258
  value.
2834
3259
  start (TEncodable): Filters the claimed entries to those that have an ID equal or greater than the specified value.
2835
- count (Optional[int]): Limits the number of claimed entries to the specified value.
3260
+ count (Optional[int]): Limits the number of claimed entries to the specified value. Default value is 100.
2836
3261
 
2837
3262
  Command response:
2838
3263
  List[Union[bytes, List[bytes]]]: A list containing the following elements:
@@ -3263,7 +3688,7 @@ class BaseBatch:
3263
3688
  Commands response:
3264
3689
  Optional[float]: The score of the member.
3265
3690
 
3266
- If there was a conflict with choosing the XX/NX/LT/GT options, the operation aborts and None is returned.
3691
+ If there was a conflict with choosing the XX/NX/LT/GT options, the operation aborts and `None` is returned.
3267
3692
  """
3268
3693
  args = [key]
3269
3694
  if existing_options:
@@ -4264,10 +4689,10 @@ class BaseBatch:
4264
4689
  elements (List[TEncodable]): A list of members to add to the HyperLogLog stored at `key`.
4265
4690
 
4266
4691
  Commands response:
4267
- int: If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
4268
- altered, then returns 1.
4692
+ bool: If the HyperLogLog is newly created, or if the HyperLogLog approximated cardinality is
4693
+ altered, then returns `True`.
4269
4694
 
4270
- Otherwise, returns 0.
4695
+ Otherwise, returns `False`.
4271
4696
  """
4272
4697
  return self.append_command(RequestType.PfAdd, [key] + elements)
4273
4698
 
@@ -4666,7 +5091,7 @@ class BaseBatch:
4666
5091
  args.extend(["VERSION", str(version)])
4667
5092
  if parameters:
4668
5093
  for var in parameters:
4669
- args.extend(str(var))
5094
+ args.append(str(var))
4670
5095
  return self.append_command(RequestType.Lolwut, args)
4671
5096
 
4672
5097
  def random_key(self: TBatch) -> TBatch:
@@ -5350,25 +5775,6 @@ class Batch(BaseBatch):
5350
5775
 
5351
5776
  """
5352
5777
 
5353
- # TODO: add SLAVEOF and all SENTINEL commands
5354
- def move(self, key: TEncodable, db_index: int) -> "Batch":
5355
- """
5356
- Move `key` from the currently selected database to the database specified by `db_index`.
5357
-
5358
- See [valkey.io](https://valkey.io/commands/move/) for more details.
5359
-
5360
- Args:
5361
- key (TEncodable): The key to move.
5362
- db_index (int): The index of the database to move `key` to.
5363
-
5364
- Commands response:
5365
- bool: True if `key` was moved.
5366
-
5367
- False if the `key` already exists in the destination database
5368
- or does not exist in the source database.
5369
- """
5370
- return self.append_command(RequestType.Move, [key, str(db_index)])
5371
-
5372
5778
  def select(self, index: int) -> "Batch":
5373
5779
  """
5374
5780
  Change the currently selected database.
@@ -5479,7 +5885,11 @@ class ClusterBatch(BaseBatch):
5479
5885
  self,
5480
5886
  source: TEncodable,
5481
5887
  destination: TEncodable,
5888
+ # TODO next major release the arguments replace and destinationDB must have their order
5889
+ # swapped to align with the standalone order.
5890
+ # At the moment of the patch release 2.1.1. we can't have a breaking change
5482
5891
  replace: Optional[bool] = None,
5892
+ destinationDB: Optional[int] = None,
5483
5893
  ) -> "ClusterBatch":
5484
5894
  """
5485
5895
  Copies the value stored at the `source` to the `destination` key. When `replace` is True,
@@ -5491,15 +5901,17 @@ class ClusterBatch(BaseBatch):
5491
5901
  source (TEncodable): The key to the source value.
5492
5902
  destination (TEncodable): The key where the value should be copied to.
5493
5903
  replace (Optional[bool]): If the destination key should be removed before copying the value to it.
5494
-
5904
+ destinationDB (Optional[int]): The alternative logical database index for the destination key.
5495
5905
  Command response:
5496
5906
  bool: True if the source was copied.
5497
5907
 
5498
5908
  Otherwise, return False.
5499
5909
 
5500
- Since: Valkey version 6.2.0.
5910
+ Since: Valkey version 9.0.0.
5501
5911
  """
5502
5912
  args = [source, destination]
5913
+ if destinationDB is not None:
5914
+ args.extend(["DB", str(destinationDB)])
5503
5915
  if replace is not None:
5504
5916
  args.append("REPLACE")
5505
5917
 
@@ -5573,13 +5985,13 @@ class ClusterBatch(BaseBatch):
5573
5985
  # TODO: add all CLUSTER commands
5574
5986
 
5575
5987
 
5576
- @deprecated(reason="Use ClusterBatch(is_atomic=True) instead.")
5988
+ @deprecated("Use Batch(is_atomic=True) instead.")
5577
5989
  class Transaction(Batch):
5578
5990
  def __init__(self):
5579
5991
  super().__init__(is_atomic=True)
5580
5992
 
5581
5993
 
5582
- @deprecated(reason="Use ClusterBatch(is_atomic=True) instead.")
5994
+ @deprecated("Use ClusterBatch(is_atomic=True) instead.")
5583
5995
  class ClusterTransaction(ClusterBatch):
5584
5996
  def __init__(self):
5585
5997
  super().__init__(is_atomic=True)