valkey-glide 2.0.0__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 (44) hide show
  1. glide/__init__.py +152 -118
  2. glide/async_commands/cluster_commands.py +29 -14
  3. glide/async_commands/core.py +600 -414
  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 +10 -51
  7. glide/glide.cpython-39-darwin.so +0 -0
  8. glide/glide.pyi +1 -1
  9. glide/glide_client.py +54 -48
  10. glide/logger.py +3 -3
  11. glide/opentelemetry.py +8 -4
  12. glide_shared/__init__.py +330 -0
  13. glide_shared/commands/__init__.py +0 -0
  14. {glide/async_commands → glide_shared/commands}/batch.py +426 -32
  15. {glide/async_commands → glide_shared/commands}/batch_options.py +1 -1
  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 +302 -58
  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}/routes.py +29 -15
  31. {valkey_glide-2.0.0.dist-info → valkey_glide-2.2.2.dist-info}/METADATA +120 -58
  32. valkey_glide-2.2.2.dist-info/RECORD +40 -0
  33. glide/protobuf/command_request_pb2.py +0 -54
  34. glide/protobuf/command_request_pb2.pyi +0 -1193
  35. glide/protobuf/connection_request_pb2.py +0 -52
  36. glide/protobuf/connection_request_pb2.pyi +0 -299
  37. glide/protobuf/response_pb2.pyi +0 -106
  38. valkey_glide-2.0.0.dist-info/RECORD +0 -39
  39. {glide/async_commands → glide_shared/commands}/bitmap.py +0 -0
  40. {glide/async_commands → glide_shared/commands}/command_args.py +0 -0
  41. {glide/async_commands → glide_shared/commands}/server_modules/ft_options/ft_constants.py +0 -0
  42. {glide → glide_shared}/protobuf/response_pb2.py +0 -0
  43. {glide → glide_shared}/protobuf_codec.py +0 -0
  44. {valkey_glide-2.0.0.dist-info → valkey_glide-2.2.2.dist-info}/WHEEL +0 -0
@@ -1,22 +1,8 @@
1
1
  # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
- from dataclasses import dataclass
3
- from datetime import datetime, timedelta
4
- from enum import Enum
5
- from typing import (
6
- Dict,
7
- List,
8
- Mapping,
9
- Optional,
10
- Protocol,
11
- Set,
12
- Tuple,
13
- Type,
14
- Union,
15
- cast,
16
- get_args,
17
- )
2
+ from typing import Dict, List, Mapping, Optional, Protocol, Set, Tuple, Union, cast
18
3
 
19
- from glide.async_commands.bitmap import (
4
+ from glide.glide import ClusterScanCursor
5
+ from glide_shared.commands.bitmap import (
20
6
  BitFieldGet,
21
7
  BitFieldSubCommands,
22
8
  BitwiseOperation,
@@ -24,8 +10,20 @@ from glide.async_commands.bitmap import (
24
10
  _create_bitfield_args,
25
11
  _create_bitfield_read_only_args,
26
12
  )
27
- from glide.async_commands.command_args import Limit, ListDirection, ObjectType, OrderBy
28
- from glide.async_commands.sorted_set import (
13
+ from glide_shared.commands.command_args import Limit, ListDirection, ObjectType, OrderBy
14
+ from glide_shared.commands.core_options import (
15
+ ConditionalChange,
16
+ ExpireOptions,
17
+ ExpiryGetEx,
18
+ ExpirySet,
19
+ HashFieldConditionalChange,
20
+ InsertPosition,
21
+ OnlyIfEqual,
22
+ PubSubMsg,
23
+ UpdateOptions,
24
+ _build_sort_args,
25
+ )
26
+ from glide_shared.commands.sorted_set import (
29
27
  AggregationType,
30
28
  GeoSearchByBox,
31
29
  GeoSearchByRadius,
@@ -43,7 +41,7 @@ from glide.async_commands.sorted_set import (
43
41
  _create_zinter_zunion_cmd_args,
44
42
  _create_zrange_args,
45
43
  )
46
- from glide.async_commands.stream import (
44
+ from glide_shared.commands.stream import (
47
45
  StreamAddOptions,
48
46
  StreamClaimOptions,
49
47
  StreamGroupOptions,
@@ -54,389 +52,16 @@ from glide.async_commands.stream import (
54
52
  StreamTrimOptions,
55
53
  _create_xpending_range_args,
56
54
  )
57
- from glide.constants import (
55
+ from glide_shared.constants import (
58
56
  TOK,
59
57
  TEncodable,
60
58
  TResult,
61
59
  TXInfoStreamFullResponse,
62
60
  TXInfoStreamResponse,
63
61
  )
64
- from glide.exceptions import RequestError
65
- from glide.protobuf.command_request_pb2 import RequestType
66
- from glide.routes import Route
67
-
68
- from ..glide import ClusterScanCursor
69
-
70
-
71
- class ConditionalChange(Enum):
72
- """
73
- A condition to the `SET`, `ZADD` and `GEOADD` commands.
74
- """
75
-
76
- ONLY_IF_EXISTS = "XX"
77
- """ Only update key / elements that already exist. Equivalent to `XX` in the Valkey API. """
78
-
79
- ONLY_IF_DOES_NOT_EXIST = "NX"
80
- """ Only set key / add elements that does not already exist. Equivalent to `NX` in the Valkey API. """
81
-
82
-
83
- @dataclass
84
- class OnlyIfEqual:
85
- """
86
- Change condition to the `SET` command,
87
- For additional conditonal options see ConditionalChange
88
-
89
- - comparison_value - value to compare to the current value of a key.
90
-
91
- If comparison_value is equal to the key, it will overwrite the value of key to the new provided value
92
- Equivalent to the IFEQ comparison-value in the Valkey API
93
- """
94
-
95
- comparison_value: TEncodable
96
-
97
-
98
- class ExpiryType(Enum):
99
- """
100
- SET option: The type of the expiry.
101
- """
102
-
103
- SEC = 0, Union[int, timedelta]
104
- """
105
- Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API.
106
- """
107
-
108
- MILLSEC = 1, Union[int, timedelta]
109
- """
110
- Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API.
111
- """
112
-
113
- UNIX_SEC = 2, Union[int, datetime]
114
- """
115
- Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API.
116
- """
117
-
118
- UNIX_MILLSEC = 3, Union[int, datetime]
119
- """
120
- Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API.
121
- """
122
-
123
- KEEP_TTL = 4, Type[None]
124
- """
125
- Retain the time to live associated with the key. Equivalent to `KEEPTTL` in the Valkey API.
126
- """
127
-
128
-
129
- class ExpiryTypeGetEx(Enum):
130
- """
131
- GetEx option: The type of the expiry.
132
- """
133
-
134
- SEC = 0, Union[int, timedelta]
135
- """ Set the specified expire time, in seconds. Equivalent to `EX` in the Valkey API. """
136
-
137
- MILLSEC = 1, Union[int, timedelta]
138
- """ Set the specified expire time, in milliseconds. Equivalent to `PX` in the Valkey API. """
139
-
140
- UNIX_SEC = 2, Union[int, datetime]
141
- """ Set the specified Unix time at which the key will expire, in seconds. Equivalent to `EXAT` in the Valkey API. """
142
-
143
- UNIX_MILLSEC = 3, Union[int, datetime]
144
- """ Set the specified Unix time at which the key will expire, in milliseconds. Equivalent to `PXAT` in the Valkey API. """
145
-
146
- PERSIST = 4, Type[None]
147
- """ Remove the time to live associated with the key. Equivalent to `PERSIST` in the Valkey API. """
148
-
149
-
150
- class InfoSection(Enum):
151
- """
152
- INFO option: a specific section of information:
153
-
154
- When no parameter is provided, the default option is assumed.
155
- """
156
-
157
- SERVER = "server"
158
- """ General information about the server """
159
-
160
- CLIENTS = "clients"
161
- """ Client connections section """
162
-
163
- MEMORY = "memory"
164
- """ Memory consumption related information """
165
-
166
- PERSISTENCE = "persistence"
167
- """ RDB and AOF related information """
168
-
169
- STATS = "stats"
170
- """ General statistics """
171
-
172
- REPLICATION = "replication"
173
- """ Master/replica replication information """
174
-
175
- CPU = "cpu"
176
- """ CPU consumption statistics """
177
-
178
- COMMAND_STATS = "commandstats"
179
- """ Valkey command statistics """
180
-
181
- LATENCY_STATS = "latencystats"
182
- """ Valkey command latency percentile distribution statistics """
183
-
184
- SENTINEL = "sentinel"
185
- """ Valkey Sentinel section (only applicable to Sentinel instances) """
186
-
187
- CLUSTER = "cluster"
188
- """ Valkey Cluster section """
189
-
190
- MODULES = "modules"
191
- """ Modules section """
192
-
193
- KEYSPACE = "keyspace"
194
- """ Database related statistics """
195
-
196
- ERROR_STATS = "errorstats"
197
- """ Valkey error statistics """
198
-
199
- ALL = "all"
200
- """ Return all sections (excluding module generated ones) """
201
-
202
- DEFAULT = "default"
203
- """ Return only the default set of sections """
204
-
205
- EVERYTHING = "everything"
206
- """ Includes all and modules """
207
-
208
-
209
- class ExpireOptions(Enum):
210
- """
211
- EXPIRE option: options for setting key expiry.
212
- """
213
-
214
- HasNoExpiry = "NX"
215
- """ Set expiry only when the key has no expiry (Equivalent to "NX" in Valkey). """
216
-
217
- HasExistingExpiry = "XX"
218
- """ Set expiry only when the key has an existing expiry (Equivalent to "XX" in Valkey). """
219
-
220
- NewExpiryGreaterThanCurrent = "GT"
221
- """
222
- Set expiry only when the new expiry is greater than the current one (Equivalent to "GT" in Valkey).
223
- """
224
-
225
- NewExpiryLessThanCurrent = "LT"
226
- """
227
- Set expiry only when the new expiry is less than the current one (Equivalent to "LT" in Valkey).
228
- """
229
-
230
-
231
- class UpdateOptions(Enum):
232
- """
233
- Options for updating elements of a sorted set key.
234
- """
235
-
236
- LESS_THAN = "LT"
237
- """ Only update existing elements if the new score is less than the current score. """
238
-
239
- GREATER_THAN = "GT"
240
- """ Only update existing elements if the new score is greater than the current score. """
241
-
242
-
243
- class ExpirySet:
244
- """
245
- SET option: Represents the expiry type and value to be executed with "SET" command.
246
-
247
- Attributes:
248
- cmd_arg (str): The expiry type.
249
- value (str): The value for the expiry type.
250
- """
251
-
252
- def __init__(
253
- self,
254
- expiry_type: ExpiryType,
255
- value: Optional[Union[int, datetime, timedelta]],
256
- ) -> None:
257
- self.set_expiry_type_and_value(expiry_type, value)
258
-
259
- def __eq__(self, other: "object") -> bool:
260
- if not isinstance(other, ExpirySet):
261
- return NotImplemented
262
- return self.expiry_type == other.expiry_type and self.value == other.value
263
-
264
- def set_expiry_type_and_value(
265
- self, expiry_type: ExpiryType, value: Optional[Union[int, datetime, timedelta]]
266
- ):
267
- """
268
- Args:
269
- expiry_type (ExpiryType): The expiry type.
270
- value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
271
- determines the type of expiration value:
272
-
273
- - SEC: Union[int, timedelta]
274
- - MILLSEC: Union[int, timedelta]
275
- - UNIX_SEC: Union[int, datetime]
276
- - UNIX_MILLSEC: Union[int, datetime]
277
- - KEEP_TTL: Type[None]
278
- """
279
- if not isinstance(value, get_args(expiry_type.value[1])):
280
- raise ValueError(
281
- f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
282
- )
283
- self.expiry_type = expiry_type
284
- if self.expiry_type == ExpiryType.SEC:
285
- self.cmd_arg = "EX"
286
- if isinstance(value, timedelta):
287
- value = int(value.total_seconds())
288
- elif self.expiry_type == ExpiryType.MILLSEC:
289
- self.cmd_arg = "PX"
290
- if isinstance(value, timedelta):
291
- value = int(value.total_seconds() * 1000)
292
- elif self.expiry_type == ExpiryType.UNIX_SEC:
293
- self.cmd_arg = "EXAT"
294
- if isinstance(value, datetime):
295
- value = int(value.timestamp())
296
- elif self.expiry_type == ExpiryType.UNIX_MILLSEC:
297
- self.cmd_arg = "PXAT"
298
- if isinstance(value, datetime):
299
- value = int(value.timestamp() * 1000)
300
- elif self.expiry_type == ExpiryType.KEEP_TTL:
301
- self.cmd_arg = "KEEPTTL"
302
- self.value = str(value) if value else None
303
-
304
- def get_cmd_args(self) -> List[str]:
305
- return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]
306
-
307
-
308
- class ExpiryGetEx:
309
- """
310
- GetEx option: Represents the expiry type and value to be executed with "GetEx" command.
311
-
312
- Attributes:
313
- cmd_arg (str): The expiry type.
314
- value (str): The value for the expiry type.
315
- """
316
-
317
- def __init__(
318
- self,
319
- expiry_type: ExpiryTypeGetEx,
320
- value: Optional[Union[int, datetime, timedelta]],
321
- ) -> None:
322
- self.set_expiry_type_and_value(expiry_type, value)
323
-
324
- def set_expiry_type_and_value(
325
- self,
326
- expiry_type: ExpiryTypeGetEx,
327
- value: Optional[Union[int, datetime, timedelta]],
328
- ):
329
- """
330
- Args:
331
- expiry_type (ExpiryType): The expiry type.
332
- value (Optional[Union[int, datetime, timedelta]]): The value of the expiration type. The type of expiration
333
- determines the type of expiration value:
334
-
335
- - SEC: Union[int, timedelta]
336
- - MILLSEC: Union[int, timedelta]
337
- - UNIX_SEC: Union[int, datetime]
338
- - UNIX_MILLSEC: Union[int, datetime]
339
- - PERSIST: Type[None]
340
- """
341
- if not isinstance(value, get_args(expiry_type.value[1])):
342
- raise ValueError(
343
- f"The value of {expiry_type} should be of type {expiry_type.value[1]}"
344
- )
345
- self.expiry_type = expiry_type
346
- if self.expiry_type == ExpiryTypeGetEx.SEC:
347
- self.cmd_arg = "EX"
348
- if isinstance(value, timedelta):
349
- value = int(value.total_seconds())
350
- elif self.expiry_type == ExpiryTypeGetEx.MILLSEC:
351
- self.cmd_arg = "PX"
352
- if isinstance(value, timedelta):
353
- value = int(value.total_seconds() * 1000)
354
- elif self.expiry_type == ExpiryTypeGetEx.UNIX_SEC:
355
- self.cmd_arg = "EXAT"
356
- if isinstance(value, datetime):
357
- value = int(value.timestamp())
358
- elif self.expiry_type == ExpiryTypeGetEx.UNIX_MILLSEC:
359
- self.cmd_arg = "PXAT"
360
- if isinstance(value, datetime):
361
- value = int(value.timestamp() * 1000)
362
- elif self.expiry_type == ExpiryTypeGetEx.PERSIST:
363
- self.cmd_arg = "PERSIST"
364
- self.value = str(value) if value else None
365
-
366
- def get_cmd_args(self) -> List[str]:
367
- return [self.cmd_arg] if self.value is None else [self.cmd_arg, self.value]
368
-
369
-
370
- class InsertPosition(Enum):
371
- BEFORE = "BEFORE"
372
- AFTER = "AFTER"
373
-
374
-
375
- class FlushMode(Enum):
376
- """
377
- Defines flushing mode for:
378
-
379
- `FLUSHALL` command and `FUNCTION FLUSH` command.
380
-
381
- See [FLUSHAL](https://valkey.io/commands/flushall/) and [FUNCTION-FLUSH](https://valkey.io/commands/function-flush/)
382
- for details
383
-
384
- SYNC was introduced in version 6.2.0.
385
- """
386
-
387
- ASYNC = "ASYNC"
388
- SYNC = "SYNC"
389
-
390
-
391
- class FunctionRestorePolicy(Enum):
392
- """
393
- Options for the FUNCTION RESTORE command.
394
- """
395
-
396
- APPEND = "APPEND"
397
- """ Appends the restored libraries to the existing libraries and aborts on collision. This is the default policy. """
398
-
399
- FLUSH = "FLUSH"
400
- """ Deletes all existing libraries before restoring the payload. """
401
-
402
- REPLACE = "REPLACE"
403
- """
404
- Appends the restored libraries to the existing libraries, replacing any existing ones in case
405
- of name collisions. Note that this policy doesn't prevent function name collisions, only libraries.
406
- """
407
-
408
-
409
- def _build_sort_args(
410
- key: TEncodable,
411
- by_pattern: Optional[TEncodable] = None,
412
- limit: Optional[Limit] = None,
413
- get_patterns: Optional[List[TEncodable]] = None,
414
- order: Optional[OrderBy] = None,
415
- alpha: Optional[bool] = None,
416
- store: Optional[TEncodable] = None,
417
- ) -> List[TEncodable]:
418
- args = [key]
419
-
420
- if by_pattern:
421
- args.extend(["BY", by_pattern])
422
-
423
- if limit:
424
- args.extend(["LIMIT", str(limit.offset), str(limit.count)])
425
-
426
- if get_patterns:
427
- for pattern in get_patterns:
428
- args.extend(["GET", pattern])
429
-
430
- if order:
431
- args.append(order.value)
432
-
433
- if alpha:
434
- args.append("ALPHA")
435
-
436
- if store:
437
- args.extend(["STORE", store])
438
-
439
- return args
62
+ from glide_shared.exceptions import RequestError
63
+ from glide_shared.protobuf.command_request_pb2 import RequestType
64
+ from glide_shared.routes import Route
440
65
 
441
66
 
442
67
  class CoreCommands(Protocol):
@@ -514,6 +139,27 @@ class CoreCommands(Protocol):
514
139
  TOK, await self._update_connection_password(password, immediate_auth)
515
140
  )
516
141
 
142
+ async def _refresh_iam_token(self) -> TResult: ...
143
+
144
+ async def refresh_iam_token(self) -> TOK:
145
+ """
146
+ Manually refresh the IAM token for the current connection.
147
+
148
+ This method is only available if the client was created with IAM authentication.
149
+ It triggers an immediate refresh of the IAM token and updates the connection.
150
+
151
+ Returns:
152
+ TOK: A simple OK response on success.
153
+
154
+ Raises:
155
+ ConfigurationError: If the client is not using IAM authentication.
156
+
157
+ Example:
158
+ >>> await client.refresh_iam_token()
159
+ 'OK'
160
+ """
161
+ return cast(TOK, await self._refresh_iam_token())
162
+
517
163
  async def set(
518
164
  self,
519
165
  key: TEncodable,
@@ -805,6 +451,34 @@ class CoreCommands(Protocol):
805
451
  """
806
452
  return cast(int, await self._execute_command(RequestType.Del, keys))
807
453
 
454
+ async def move(self, key: TEncodable, db_index: int) -> bool:
455
+ """
456
+ Move key from the currently selected database to the specified destination database.
457
+
458
+ Note:
459
+ For cluster mode move command is supported since Valkey 9.0.0
460
+
461
+ See [valkey.io](https://valkey.io/commands/move/) for more details.
462
+
463
+ Args:
464
+ key (TEncodable): The key to move.
465
+ db_index (int): The destination database number.
466
+
467
+ Returns:
468
+ bool: True if the key was moved successfully, False if the key does not exist
469
+ or was already present in the destination database.
470
+
471
+ Examples:
472
+ >>> await client.move("some_key", 1)
473
+ True # The key was successfully moved to database 1
474
+ >>> await client.move("nonexistent_key", 1)
475
+ False # The key does not exist
476
+ """
477
+ return cast(
478
+ bool,
479
+ await self._execute_command(RequestType.Move, [key, str(db_index)]),
480
+ )
481
+
808
482
  async def incr(self, key: TEncodable) -> int:
809
483
  """
810
484
  Increments the number stored at `key` by one. If the key does not exist, it is set to 0 before performing the
@@ -1478,6 +1152,519 @@ class CoreCommands(Protocol):
1478
1152
  await self._execute_command(RequestType.HStrlen, [key, field]),
1479
1153
  )
1480
1154
 
1155
+ async def httl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
1156
+ """
1157
+ Returns the remaining time to live (in seconds) of hash key's field(s) that have an associated expiration.
1158
+
1159
+ See [valkey.io](https://valkey.io/commands/httl/) for more details.
1160
+
1161
+ Args:
1162
+ key (TEncodable): The key of the hash.
1163
+ fields (List[TEncodable]): The list of fields to get TTL for.
1164
+
1165
+ Returns:
1166
+ List[int]: A list of TTL values for each field:
1167
+ - Positive integer: remaining TTL in seconds
1168
+ - `-1`: field exists but has no expiration
1169
+ - `-2`: field does not exist or key does not exist
1170
+
1171
+ Examples:
1172
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
1173
+ >>> await client.httl("my_hash", ["field1", "field2", "non_existent_field"])
1174
+ [9, 9, -2] # field1 and field2 have ~9 seconds left, non_existent_field doesn't exist
1175
+
1176
+ Since: Valkey 9.0.0
1177
+ """
1178
+ return cast(
1179
+ List[int],
1180
+ await self._execute_command(
1181
+ RequestType.HTtl, [key, "FIELDS", str(len(fields))] + fields
1182
+ ),
1183
+ )
1184
+
1185
+ async def hpttl(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
1186
+ """
1187
+ Returns the remaining time to live (in milliseconds) of hash key's field(s) that have an associated expiration.
1188
+
1189
+ See [valkey.io](https://valkey.io/commands/hpttl/) for more details.
1190
+
1191
+ Args:
1192
+ key (TEncodable): The key of the hash.
1193
+ fields (List[TEncodable]): The list of fields to get TTL for.
1194
+
1195
+ Returns:
1196
+ List[int]: A list of TTL values for each field:
1197
+ - Positive integer: remaining TTL in milliseconds
1198
+ - `-1`: field exists but has no expiration
1199
+ - `-2`: field does not exist or key does not exist
1200
+
1201
+ Examples:
1202
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
1203
+ >>> await client.hpttl("my_hash", ["field1", "field2", "non_existent_field"])
1204
+ [9500, 9500, -2] # field1 and field2 have ~9500 milliseconds left, non_existent_field doesn't exist
1205
+
1206
+ Since: Valkey 9.0.0
1207
+ """
1208
+ return cast(
1209
+ List[int],
1210
+ await self._execute_command(
1211
+ RequestType.HPTtl, [key, "FIELDS", str(len(fields))] + fields
1212
+ ),
1213
+ )
1214
+
1215
+ async def hexpiretime(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
1216
+ """
1217
+ Returns the expiration Unix timestamp (in seconds) of hash key's field(s) that have an associated expiration.
1218
+
1219
+ See [valkey.io](https://valkey.io/commands/hexpiretime/) for more details.
1220
+
1221
+ Args:
1222
+ key (TEncodable): The key of the hash.
1223
+ fields (List[TEncodable]): The list of fields to get expiration timestamps for.
1224
+
1225
+ Returns:
1226
+ List[int]: A list of expiration timestamps for each field:
1227
+ - Positive integer: absolute expiration timestamp in seconds (Unix timestamp)
1228
+ - `-1`: field exists but has no expiration
1229
+ - `-2`: field does not exist or key does not exist
1230
+
1231
+ Examples:
1232
+ >>> import time
1233
+ >>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
1234
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_SEC, future_timestamp))
1235
+ >>> await client.hexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
1236
+ [future_timestamp, future_timestamp, -2] # field1 and field2 expire at future_timestamp, non_existent_field doesn't exist
1237
+
1238
+ Since: Valkey 9.0.0
1239
+ """
1240
+ return cast(
1241
+ List[int],
1242
+ await self._execute_command(
1243
+ RequestType.HExpireTime, [key, "FIELDS", str(len(fields))] + fields
1244
+ ),
1245
+ )
1246
+
1247
+ async def hpexpiretime(
1248
+ self, key: TEncodable, fields: List[TEncodable]
1249
+ ) -> List[int]:
1250
+ """
1251
+ Returns the expiration Unix timestamp (in milliseconds) of hash key's field(s) that have an associated expiration.
1252
+
1253
+ See [valkey.io](https://valkey.io/commands/hpexpiretime/) for more details.
1254
+
1255
+ Args:
1256
+ key (TEncodable): The key of the hash.
1257
+ fields (List[TEncodable]): The list of fields to get expiration timestamps for.
1258
+
1259
+ Returns:
1260
+ List[int]: A list of expiration timestamps for each field:
1261
+ - Positive integer: absolute expiration timestamp in milliseconds (Unix timestamp in ms)
1262
+ - `-1`: field exists but has no expiration
1263
+ - `-2`: field does not exist or key does not exist
1264
+
1265
+ Examples:
1266
+ >>> import time
1267
+ >>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
1268
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.UNIX_MILLSEC, future_timestamp_ms))
1269
+ >>> await client.hpexpiretime("my_hash", ["field1", "field2", "non_existent_field"])
1270
+ [future_timestamp_ms, future_timestamp_ms, -2] # field1 and field2 expire at future_timestamp_ms, non_existent_field doesn't exist
1271
+
1272
+ Since: Valkey 9.0.0
1273
+ """
1274
+ return cast(
1275
+ List[int],
1276
+ await self._execute_command(
1277
+ RequestType.HPExpireTime, [key, "FIELDS", str(len(fields))] + fields
1278
+ ),
1279
+ )
1280
+
1281
+ async def hsetex(
1282
+ self,
1283
+ key: TEncodable,
1284
+ field_value_map: Mapping[TEncodable, TEncodable],
1285
+ field_conditional_change: Optional[HashFieldConditionalChange] = None,
1286
+ expiry: Optional[ExpirySet] = None,
1287
+ ) -> int:
1288
+ """
1289
+ Sets the specified fields to their respective values in the hash stored at `key` with optional expiration.
1290
+
1291
+ See [valkey.io](https://valkey.io/commands/hsetex/) for more details.
1292
+
1293
+ Args:
1294
+ key (TEncodable): The key of the hash.
1295
+ field_value_map (Mapping[TEncodable, TEncodable]): A field-value map consisting of fields and their corresponding
1296
+ values to be set in the hash stored at the specified key.
1297
+ field_conditional_change (Optional[HashFieldConditionalChange]): Field conditional change option:
1298
+ - ONLY_IF_ALL_EXIST (FXX): Only set fields if all of them already exist.
1299
+ - ONLY_IF_NONE_EXIST (FNX): Only set fields if none of them already exist.
1300
+ expiry (Optional[ExpirySet]): Expiration options for the fields:
1301
+ - SEC (EX): Expiration time in seconds.
1302
+ - MILLSEC (PX): Expiration time in milliseconds.
1303
+ - UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
1304
+ - UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
1305
+ - KEEP_TTL (KEEPTTL): Retain existing TTL.
1306
+
1307
+ Returns:
1308
+ int: 1 if all fields were set successfully, 0 if none were set due to conditional constraints.
1309
+
1310
+ Examples:
1311
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
1312
+ 1 # All fields set with 10 second expiration
1313
+ >>> await client.hsetex("my_hash", {"field3": "value3"}, field_conditional_change=HashFieldConditionalChange.ONLY_IF_ALL_EXIST)
1314
+ 1 # Field set because field already exists
1315
+ >>> await client.hsetex("new_hash", {"field1": "value1"}, field_conditional_change=HashFieldConditionalChange.ONLY_IF_ALL_EXIST)
1316
+ 0 # No fields set because hash doesn't exist
1317
+
1318
+ Since: Valkey 9.0.0
1319
+ """
1320
+ args: List[TEncodable] = [key]
1321
+
1322
+ # Add field conditional change option if specified
1323
+ if field_conditional_change is not None:
1324
+ args.append(field_conditional_change.value)
1325
+
1326
+ # Add expiry options if specified
1327
+ if expiry is not None:
1328
+ args.extend(expiry.get_cmd_args())
1329
+
1330
+ # Add FIELDS keyword and field count
1331
+ args.extend(["FIELDS", str(len(field_value_map))])
1332
+
1333
+ # Add field-value pairs
1334
+ for field, value in field_value_map.items():
1335
+ args.extend([field, value])
1336
+
1337
+ return cast(
1338
+ int,
1339
+ await self._execute_command(RequestType.HSetEx, args),
1340
+ )
1341
+
1342
+ async def hgetex(
1343
+ self,
1344
+ key: TEncodable,
1345
+ fields: List[TEncodable],
1346
+ expiry: Optional[ExpiryGetEx] = None,
1347
+ ) -> Optional[List[Optional[bytes]]]:
1348
+ """
1349
+ Retrieves the values of specified fields in the hash stored at `key` and optionally sets their expiration.
1350
+
1351
+ See [valkey.io](https://valkey.io/commands/hgetex/) for more details.
1352
+
1353
+ Args:
1354
+ key (TEncodable): The key of the hash.
1355
+ fields (List[TEncodable]): The list of fields to retrieve from the hash.
1356
+ expiry (Optional[ExpiryGetEx]): Expiration options for the retrieved fields:
1357
+ - SEC (EX): Expiration time in seconds.
1358
+ - MILLSEC (PX): Expiration time in milliseconds.
1359
+ - UNIX_SEC (EXAT): Absolute expiration time in seconds (Unix timestamp).
1360
+ - UNIX_MILLSEC (PXAT): Absolute expiration time in milliseconds (Unix timestamp).
1361
+ - PERSIST: Remove expiration from the fields.
1362
+
1363
+ Returns:
1364
+ Optional[List[Optional[bytes]]]: A list of values associated with the given fields, in the same order as requested.
1365
+ For every field that does not exist in the hash, a null value is returned.
1366
+ If `key` does not exist, it is treated as an empty hash, and the function returns a list of null values.
1367
+
1368
+ Examples:
1369
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
1370
+ >>> await client.hgetex("my_hash", ["field1", "field2"])
1371
+ [b"value1", b"value2"]
1372
+ >>> await client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.SEC, 20))
1373
+ [b"value1"] # field1 now has 20 second expiration
1374
+ >>> await client.hgetex("my_hash", ["field1"], expiry=ExpiryGetEx(ExpiryTypeGetEx.PERSIST, None))
1375
+ [b"value1"] # field1 expiration removed
1376
+
1377
+ Since: Valkey 9.0.0
1378
+ """
1379
+ args: List[TEncodable] = [key]
1380
+
1381
+ # Add expiry options if specified
1382
+ if expiry is not None:
1383
+ args.extend(expiry.get_cmd_args())
1384
+
1385
+ # Add FIELDS keyword and field count
1386
+ args.extend(["FIELDS", str(len(fields))])
1387
+
1388
+ # Add fields
1389
+ args.extend(fields)
1390
+
1391
+ return cast(
1392
+ Optional[List[Optional[bytes]]],
1393
+ await self._execute_command(RequestType.HGetEx, args),
1394
+ )
1395
+
1396
+ async def hexpire(
1397
+ self,
1398
+ key: TEncodable,
1399
+ seconds: int,
1400
+ fields: List[TEncodable],
1401
+ option: Optional[ExpireOptions] = None,
1402
+ ) -> List[int]:
1403
+ """
1404
+ Sets expiration time in seconds for one or more hash fields.
1405
+
1406
+ See [valkey.io](https://valkey.io/commands/hexpire/) for more details.
1407
+
1408
+ Args:
1409
+ key (TEncodable): The key of the hash.
1410
+ seconds (int): The expiration time in seconds.
1411
+ fields (List[TEncodable]): The list of fields to set expiration for.
1412
+ option (Optional[ExpireOptions]): Conditional expiration option:
1413
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1414
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1415
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1416
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1417
+
1418
+ Returns:
1419
+ List[int]: A list of status codes for each field:
1420
+ - `1`: Expiration time was applied successfully.
1421
+ - `0`: Specified condition was not met.
1422
+ - `-2`: Field does not exist or key does not exist.
1423
+ - `2`: Field was deleted immediately (when seconds is 0 or timestamp is in the past).
1424
+
1425
+ Examples:
1426
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
1427
+ >>> await client.hexpire("my_hash", 20, ["field1", "field2"])
1428
+ [1, 1] # Both fields' expiration set to 20 seconds
1429
+ >>> await client.hexpire("my_hash", 30, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
1430
+ [1] # field1 expiration updated to 30 seconds (greater than current 20)
1431
+ >>> await client.hexpire("my_hash", 0, ["field2"])
1432
+ [2] # field2 deleted immediately
1433
+ >>> await client.hexpire("my_hash", 10, ["non_existent_field"])
1434
+ [-2] # Field doesn't exist
1435
+
1436
+ Since: Valkey 9.0.0
1437
+ """
1438
+ args: List[TEncodable] = [key, str(seconds)]
1439
+
1440
+ # Add conditional option if specified
1441
+ if option is not None:
1442
+ args.append(option.value)
1443
+
1444
+ # Add FIELDS keyword and field count
1445
+ args.extend(["FIELDS", str(len(fields))])
1446
+
1447
+ # Add fields
1448
+ args.extend(fields)
1449
+
1450
+ return cast(
1451
+ List[int],
1452
+ await self._execute_command(RequestType.HExpire, args),
1453
+ )
1454
+
1455
+ async def hpersist(self, key: TEncodable, fields: List[TEncodable]) -> List[int]:
1456
+ """
1457
+ Removes the expiration from one or more hash fields, making them persistent.
1458
+
1459
+ See [valkey.io](https://valkey.io/commands/hpersist/) for more details.
1460
+
1461
+ Args:
1462
+ key (TEncodable): The key of the hash.
1463
+ fields (List[TEncodable]): The list of fields to remove expiration from.
1464
+
1465
+ Returns:
1466
+ List[int]: A list of status codes for each field:
1467
+ - `1`: Expiration was removed successfully (field became persistent).
1468
+ - `-1`: Field exists but has no expiration.
1469
+ - `-2`: Field does not exist or key does not exist.
1470
+
1471
+ Examples:
1472
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
1473
+ >>> await client.hpersist("my_hash", ["field1", "field2"])
1474
+ [1, 1] # Both fields made persistent
1475
+ >>> await client.hpersist("my_hash", ["field1"])
1476
+ [-1] # field1 already persistent
1477
+ >>> await client.hpersist("my_hash", ["non_existent_field"])
1478
+ [-2] # Field doesn't exist
1479
+
1480
+ Since: Valkey 9.0.0
1481
+ """
1482
+ args: List[TEncodable] = [key, "FIELDS", str(len(fields))] + fields
1483
+
1484
+ return cast(
1485
+ List[int],
1486
+ await self._execute_command(RequestType.HPersist, args),
1487
+ )
1488
+
1489
+ async def hpexpire(
1490
+ self,
1491
+ key: TEncodable,
1492
+ milliseconds: int,
1493
+ fields: List[TEncodable],
1494
+ option: Optional[ExpireOptions] = None,
1495
+ ) -> List[int]:
1496
+ """
1497
+ Sets expiration time in milliseconds for one or more hash fields.
1498
+
1499
+ See [valkey.io](https://valkey.io/commands/hpexpire/) for more details.
1500
+
1501
+ Args:
1502
+ key (TEncodable): The key of the hash.
1503
+ milliseconds (int): The expiration time in milliseconds.
1504
+ fields (List[TEncodable]): The list of fields to set expiration for.
1505
+ option (Optional[ExpireOptions]): Conditional expiration option:
1506
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1507
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1508
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1509
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1510
+
1511
+ Returns:
1512
+ List[int]: A list of status codes for each field:
1513
+ - `1`: Expiration time was applied successfully.
1514
+ - `0`: Specified condition was not met.
1515
+ - `-2`: Field does not exist or key does not exist.
1516
+ - `2`: Field was deleted immediately (when milliseconds is 0 or timestamp is in the past).
1517
+
1518
+ Examples:
1519
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
1520
+ >>> await client.hpexpire("my_hash", 20000, ["field1", "field2"])
1521
+ [1, 1] # Both fields' expiration set to 20000 milliseconds
1522
+ >>> await client.hpexpire("my_hash", 30000, ["field1"], option=ExpireOptions.NewExpiryGreaterThanCurrent)
1523
+ [1] # field1 expiration updated to 30000 milliseconds (greater than current 20000)
1524
+ >>> await client.hpexpire("my_hash", 0, ["field2"])
1525
+ [2] # field2 deleted immediately
1526
+ >>> await client.hpexpire("my_hash", 10000, ["non_existent_field"])
1527
+ [-2] # Field doesn't exist
1528
+
1529
+ Since: Valkey 9.0.0
1530
+ """
1531
+ args: List[TEncodable] = [key, str(milliseconds)]
1532
+
1533
+ # Add conditional option if specified
1534
+ if option is not None:
1535
+ args.append(option.value)
1536
+
1537
+ # Add FIELDS keyword and field count
1538
+ args.extend(["FIELDS", str(len(fields))])
1539
+
1540
+ # Add fields
1541
+ args.extend(fields)
1542
+
1543
+ return cast(
1544
+ List[int],
1545
+ await self._execute_command(RequestType.HPExpire, args),
1546
+ )
1547
+
1548
+ async def hexpireat(
1549
+ self,
1550
+ key: TEncodable,
1551
+ unix_timestamp: int,
1552
+ fields: List[TEncodable],
1553
+ option: Optional[ExpireOptions] = None,
1554
+ ) -> List[int]:
1555
+ """
1556
+ Sets expiration time at absolute Unix timestamp in seconds for one or more hash fields.
1557
+
1558
+ See [valkey.io](https://valkey.io/commands/hexpireat/) for more details.
1559
+
1560
+ Args:
1561
+ key (TEncodable): The key of the hash.
1562
+ unix_timestamp (int): The absolute expiration time as Unix timestamp in seconds.
1563
+ fields (List[TEncodable]): The list of fields to set expiration for.
1564
+ option (Optional[ExpireOptions]): Conditional expiration option:
1565
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1566
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1567
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1568
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1569
+
1570
+ Returns:
1571
+ List[int]: A list of status codes for each field:
1572
+ - `1`: Expiration time was applied successfully.
1573
+ - `0`: Specified condition was not met.
1574
+ - `-2`: Field does not exist or key does not exist.
1575
+ - `2`: Field was deleted immediately (when timestamp is in the past).
1576
+
1577
+ Examples:
1578
+ >>> import time
1579
+ >>> future_timestamp = int(time.time()) + 60 # 60 seconds from now
1580
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.SEC, 10))
1581
+ >>> await client.hexpireat("my_hash", future_timestamp, ["field1", "field2"])
1582
+ [1, 1] # Both fields' expiration set to future_timestamp
1583
+ >>> past_timestamp = int(time.time()) - 60 # 60 seconds ago
1584
+ >>> await client.hexpireat("my_hash", past_timestamp, ["field1"])
1585
+ [2] # field1 deleted immediately (past timestamp)
1586
+ >>> await client.hexpireat("my_hash", future_timestamp, ["non_existent_field"])
1587
+ [-2] # Field doesn't exist
1588
+
1589
+ Since: Valkey 9.0.0
1590
+ """
1591
+ args: List[TEncodable] = [key, str(unix_timestamp)]
1592
+
1593
+ # Add conditional option if specified
1594
+ if option is not None:
1595
+ args.append(option.value)
1596
+
1597
+ # Add FIELDS keyword and field count
1598
+ args.extend(["FIELDS", str(len(fields))])
1599
+
1600
+ # Add fields
1601
+ args.extend(fields)
1602
+
1603
+ return cast(
1604
+ List[int],
1605
+ await self._execute_command(RequestType.HExpireAt, args),
1606
+ )
1607
+
1608
+ async def hpexpireat(
1609
+ self,
1610
+ key: TEncodable,
1611
+ unix_timestamp_ms: int,
1612
+ fields: List[TEncodable],
1613
+ option: Optional[ExpireOptions] = None,
1614
+ ) -> List[int]:
1615
+ """
1616
+ Sets expiration time at absolute Unix timestamp in milliseconds for one or more hash fields.
1617
+
1618
+ See [valkey.io](https://valkey.io/commands/hpexpireat/) for more details.
1619
+
1620
+ Args:
1621
+ key (TEncodable): The key of the hash.
1622
+ unix_timestamp_ms (int): The absolute expiration time as Unix timestamp in milliseconds.
1623
+ fields (List[TEncodable]): The list of fields to set expiration for.
1624
+ option (Optional[ExpireOptions]): Conditional expiration option:
1625
+ - HasNoExpiry (NX): Set expiration only when the field has no expiry.
1626
+ - HasExistingExpiry (XX): Set expiration only when the field has an existing expiry.
1627
+ - NewExpiryGreaterThanCurrent (GT): Set expiration only when the new expiry is greater than the current one.
1628
+ - NewExpiryLessThanCurrent (LT): Set expiration only when the new expiry is less than the current one.
1629
+
1630
+ Returns:
1631
+ List[int]: A list of status codes for each field:
1632
+ - `1`: Expiration time was applied successfully.
1633
+ - `0`: Specified condition was not met.
1634
+ - `-2`: Field does not exist or key does not exist.
1635
+ - `2`: Field was deleted immediately (when timestamp is in the past).
1636
+
1637
+ Examples:
1638
+ >>> import time
1639
+ >>> future_timestamp_ms = int(time.time() * 1000) + 60000 # 60 seconds from now in milliseconds
1640
+ >>> await client.hsetex("my_hash", {"field1": "value1", "field2": "value2"}, expiry=ExpirySet(ExpiryType.MILLSEC, 10000))
1641
+ >>> await client.hpexpireat("my_hash", future_timestamp_ms, ["field1", "field2"])
1642
+ [1, 1] # Both fields' expiration set to future_timestamp_ms
1643
+ >>> past_timestamp_ms = int(time.time() * 1000) - 60000 # 60 seconds ago in milliseconds
1644
+ >>> await client.hpexpireat("my_hash", past_timestamp_ms, ["field1"])
1645
+ [2] # field1 deleted immediately (past timestamp)
1646
+ >>> await client.hpexpireat("my_hash", future_timestamp_ms, ["non_existent_field"])
1647
+ [-2] # Field doesn't exist
1648
+
1649
+ Since: Valkey 9.0.0
1650
+ """
1651
+ args: List[TEncodable] = [key, str(unix_timestamp_ms)]
1652
+
1653
+ # Add conditional option if specified
1654
+ if option is not None:
1655
+ args.append(option.value)
1656
+
1657
+ # Add FIELDS keyword and field count
1658
+ args.extend(["FIELDS", str(len(fields))])
1659
+
1660
+ # Add fields
1661
+ args.extend(fields)
1662
+
1663
+ return cast(
1664
+ List[int],
1665
+ await self._execute_command(RequestType.HPExpireAt, args),
1666
+ )
1667
+
1481
1668
  async def lpush(self, key: TEncodable, elements: List[TEncodable]) -> int:
1482
1669
  """
1483
1670
  Insert all the specified values at the head of the list stored at `key`.
@@ -2104,6 +2291,20 @@ class CoreCommands(Protocol):
2104
2291
  """
2105
2292
  return cast(int, await self._execute_command(RequestType.SAdd, [key] + members))
2106
2293
 
2294
+ async def select(self, index: int) -> TOK:
2295
+ """
2296
+ Change the currently selected database.
2297
+
2298
+ See [valkey.io](https://valkey.io/commands/select/) for details.
2299
+
2300
+ Args:
2301
+ index (int): The index of the database to select.
2302
+
2303
+ Returns:
2304
+ A simple OK response.
2305
+ """
2306
+ return cast(TOK, await self._execute_command(RequestType.Select, [str(index)]))
2307
+
2107
2308
  async def srem(self, key: TEncodable, members: List[TEncodable]) -> int:
2108
2309
  """
2109
2310
  Remove specified members from the set stored at `key`.
@@ -6994,7 +7195,7 @@ class CoreCommands(Protocol):
6994
7195
  See [valkey.io](https://valkey.io/commands/watch) for more details.
6995
7196
 
6996
7197
  Note:
6997
- In cluster mode, if keys in `key_value_map` map to different hash slots,
7198
+ In cluster mode, if keys in `keys` map to different hash slots,
6998
7199
  the command will be split across these slots and executed separately for each.
6999
7200
  This means the command is atomic only at the slot level. If one or more slot-specific
7000
7201
  requests fail, the entire call will return the first encountered error, even
@@ -7013,7 +7214,7 @@ class CoreCommands(Protocol):
7013
7214
  'OK'
7014
7215
  >>> transaction.set("sampleKey", "foobar")
7015
7216
  >>> await client.exec(transaction)
7016
- 'OK' # Executes successfully and keys are unwatched.
7217
+ ['OK'] # Executes successfully and keys are unwatched.
7017
7218
 
7018
7219
  >>> await client.watch("sampleKey")
7019
7220
  'OK'
@@ -7029,21 +7230,6 @@ class CoreCommands(Protocol):
7029
7230
  await self._execute_command(RequestType.Watch, keys),
7030
7231
  )
7031
7232
 
7032
- @dataclass
7033
- class PubSubMsg:
7034
- """
7035
- Describes the incoming pubsub message
7036
-
7037
- Attributes:
7038
- message (TEncodable): Incoming message.
7039
- channel (TEncodable): Name of an channel that triggered the message.
7040
- pattern (Optional[TEncodable]): Pattern that triggered the message.
7041
- """
7042
-
7043
- message: TEncodable
7044
- channel: TEncodable
7045
- pattern: Optional[TEncodable]
7046
-
7047
7233
  async def get_pubsub_message(self) -> PubSubMsg:
7048
7234
  """
7049
7235
  Returns the next pubsub message.