valkey-glide 2.1.0rc8__cp313-cp313-macosx_10_7_x86_64.whl → 2.1.1__cp313-cp313-macosx_10_7_x86_64.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.

Potentially problematic release.


This version of valkey-glide might be problematic. Click here for more details.

glide/__init__.py CHANGED
@@ -1,5 +1,9 @@
1
1
  # Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
2
2
 
3
+ import sys
4
+ import types
5
+ import warnings
6
+
3
7
  from glide.glide import (
4
8
  ClusterScanCursor,
5
9
  OpenTelemetryConfig,
@@ -159,6 +163,56 @@ from .glide_client import GlideClient, GlideClusterClient, TGlideClient
159
163
  from .logger import Level as LogLevel
160
164
  from .logger import Logger
161
165
 
166
+ _glide_module = sys.modules[__name__]
167
+
168
+ _legacy_modules = [
169
+ "glide.exceptions",
170
+ "glide.config",
171
+ "glide.constants",
172
+ "glide.routes",
173
+ "glide.async_commands",
174
+ "glide.async_commands.batch",
175
+ "glide.async_commands.batch_options",
176
+ "glide.async_commands.bitmap",
177
+ "glide.async_commands.command_args",
178
+ "glide.async_commands.server_modules",
179
+ "glide.async_commands.server_modules.ft_options",
180
+ "glide.async_commands.server_modules.ft_options.ft_aggregate_options",
181
+ "glide.async_commands.server_modules.ft_options.ft_create_options",
182
+ "glide.async_commands.server_modules.ft_options.ft_profile_options",
183
+ "glide.async_commands.server_modules.ft_options.ft_search_options",
184
+ "glide.async_commands.server_modules.glide_json",
185
+ "glide.async_commands.sorted_set",
186
+ "glide.async_commands.stream",
187
+ ]
188
+
189
+
190
+ class _LegacyModule(types.ModuleType):
191
+ """Proxy for a deprecated module that warns when first accessed."""
192
+
193
+ def __init__(self, name):
194
+ super().__init__(name)
195
+ self._warned = False
196
+
197
+ def __getattr__(self, name):
198
+ if not self._warned:
199
+ warnings.warn(
200
+ f"Importing from '{self.__name__}' is deprecated. "
201
+ f"Please import directly from 'glide' instead.",
202
+ DeprecationWarning,
203
+ stacklevel=2,
204
+ )
205
+ self._warned = True
206
+
207
+ # Access the attribute from the real top-level glide module
208
+ return getattr(_glide_module, name)
209
+
210
+
211
+ # Replace old modules with lazy proxy modules
212
+ for old_name in _legacy_modules:
213
+ if old_name not in sys.modules:
214
+ sys.modules[old_name] = _LegacyModule(old_name)
215
+
162
216
  __all__ = [
163
217
  # Client
164
218
  "TGlideClient",
@@ -1066,11 +1066,17 @@ class ClusterCommands(CoreCommands):
1066
1066
  self,
1067
1067
  source: TEncodable,
1068
1068
  destination: TEncodable,
1069
+ # TODO next major release the arguments replace and destinationDB must have their order
1070
+ # swapped to align with the standalone order.
1071
+ # At the moment of the patch release 2.1.1. we can't have a breaking change
1069
1072
  replace: Optional[bool] = None,
1073
+ destinationDB: Optional[int] = None,
1070
1074
  ) -> bool:
1071
1075
  """
1072
- Copies the value stored at the `source` to the `destination` key. When `replace` is True,
1073
- removes the `destination` key first if it already exists, otherwise performs no action.
1076
+ Copies the value stored at the `source` to the `destination` key. If `destinationDB`
1077
+ is specified, the value will be copied to the database specified by `destinationDB`,
1078
+ otherwise the current database will be used. When `replace` is True, removes the
1079
+ `destination` key first if it already exists, otherwise performs no action.
1074
1080
 
1075
1081
  See [valkey.io](https://valkey.io/commands/copy) for more details.
1076
1082
 
@@ -1081,6 +1087,7 @@ class ClusterCommands(CoreCommands):
1081
1087
  source (TEncodable): The key to the source value.
1082
1088
  destination (TEncodable): The key where the value should be copied to.
1083
1089
  replace (Optional[bool]): If the destination key should be removed before copying the value to it.
1090
+ destinationDB (Optional[int]): The alternative logical database index for the destination key.
1084
1091
 
1085
1092
  Returns:
1086
1093
  bool: True if the source was copied. Otherwise, returns False.
@@ -1089,12 +1096,20 @@ class ClusterCommands(CoreCommands):
1089
1096
  >>> await client.set("source", "sheep")
1090
1097
  >>> await client.copy(b"source", b"destination")
1091
1098
  True # Source was copied
1099
+ >>> await client.copy(b"source", b"destination", destinationDB=1)
1100
+ True # Source was copied to DB 1
1101
+ >>> await client.select(1)
1092
1102
  >>> await client.get("destination")
1093
1103
  b"sheep"
1094
1104
 
1095
1105
  Since: Valkey version 6.2.0.
1106
+ The destinationDB argument is available since Valkey 9.0.0
1096
1107
  """
1108
+
1109
+ # Build command arguments
1097
1110
  args: List[TEncodable] = [source, destination]
1111
+ if destinationDB is not None:
1112
+ args.extend(["DB", str(destinationDB)])
1098
1113
  if replace is True:
1099
1114
  args.append("REPLACE")
1100
1115
  return cast(
@@ -430,6 +430,34 @@ class CoreCommands(Protocol):
430
430
  """
431
431
  return cast(int, await self._execute_command(RequestType.Del, keys))
432
432
 
433
+ async def move(self, key: TEncodable, db_index: int) -> bool:
434
+ """
435
+ Move key from the currently selected database to the specified destination database.
436
+
437
+ Note:
438
+ For cluster mode move command is supported since Valkey 9.0.0
439
+
440
+ See [valkey.io](https://valkey.io/commands/move/) for more details.
441
+
442
+ Args:
443
+ key (TEncodable): The key to move.
444
+ db_index (int): The destination database number.
445
+
446
+ Returns:
447
+ bool: True if the key was moved successfully, False if the key does not exist
448
+ or was already present in the destination database.
449
+
450
+ Examples:
451
+ >>> await client.move("some_key", 1)
452
+ True # The key was successfully moved to database 1
453
+ >>> await client.move("nonexistent_key", 1)
454
+ False # The key does not exist
455
+ """
456
+ return cast(
457
+ bool,
458
+ await self._execute_command(RequestType.Move, [key, str(db_index)]),
459
+ )
460
+
433
461
  async def incr(self, key: TEncodable) -> int:
434
462
  """
435
463
  Increments the number stored at `key` by one. If the key does not exist, it is set to 0 before performing the
@@ -2242,6 +2270,20 @@ class CoreCommands(Protocol):
2242
2270
  """
2243
2271
  return cast(int, await self._execute_command(RequestType.SAdd, [key] + members))
2244
2272
 
2273
+ async def select(self, index: int) -> TOK:
2274
+ """
2275
+ Change the currently selected database.
2276
+
2277
+ See [valkey.io](https://valkey.io/commands/select/) for details.
2278
+
2279
+ Args:
2280
+ index (int): The index of the database to select.
2281
+
2282
+ Returns:
2283
+ A simple OK response.
2284
+ """
2285
+ return cast(TOK, await self._execute_command(RequestType.Select, [str(index)]))
2286
+
2245
2287
  async def srem(self, key: TEncodable, members: List[TEncodable]) -> int:
2246
2288
  """
2247
2289
  Remove specified members from the set stored at `key`.
@@ -162,42 +162,6 @@ class StandaloneCommands(CoreCommands):
162
162
  timeout=timeout,
163
163
  )
164
164
 
165
- async def select(self, index: int) -> TOK:
166
- """
167
- Change the currently selected database.
168
-
169
- **WARNING**: This command is NOT RECOMMENDED for production use.
170
- Upon reconnection, the client will revert to the database_id specified
171
- in the client configuration (default: 0), NOT the database selected
172
- via this command.
173
-
174
- **RECOMMENDED APPROACH**: Use the database_id parameter in client
175
- configuration instead:
176
-
177
- ```python
178
- client = await GlideClient.create_client(
179
- GlideClientConfiguration(
180
- addresses=[NodeAddress("localhost", 6379)],
181
- database_id=5 # Recommended: persists across reconnections
182
- )
183
- )
184
- ```
185
-
186
- **RECONNECTION BEHAVIOR**: After any reconnection (due to network issues,
187
- timeouts, etc.), the client will automatically revert to the database_id
188
- specified during client creation, losing any database selection made via
189
- this SELECT command.
190
-
191
- See [valkey.io](https://valkey.io/commands/select/) for details.
192
-
193
- Args:
194
- index (int): The index of the database to select.
195
-
196
- Returns:
197
- A simple OK response.
198
- """
199
- return cast(TOK, await self._execute_command(RequestType.Select, [str(index)]))
200
-
201
165
  async def config_resetstat(self) -> TOK:
202
166
  """
203
167
  Resets the statistics reported by the server using the INFO and LATENCY HISTOGRAM commands.
@@ -651,31 +615,6 @@ class StandaloneCommands(CoreCommands):
651
615
  await self._execute_command(RequestType.LastSave, []),
652
616
  )
653
617
 
654
- async def move(self, key: TEncodable, db_index: int) -> bool:
655
- """
656
- Move `key` from the currently selected database to the database specified by `db_index`.
657
-
658
- See [valkey.io](https://valkey.io/commands/move/) for more details.
659
-
660
- Args:
661
- key (TEncodable): The key to move.
662
- db_index (int): The index of the database to move `key` to.
663
-
664
- Returns:
665
- bool: `True` if `key` was moved.
666
-
667
- `False` if the `key` already exists in the destination database
668
- or does not exist in the source database.
669
-
670
- Example:
671
- >>> await client.move("some_key", 1)
672
- True
673
- """
674
- return cast(
675
- bool,
676
- await self._execute_command(RequestType.Move, [key, str(db_index)]),
677
- )
678
-
679
618
  async def publish(self, message: TEncodable, channel: TEncodable) -> int:
680
619
  """
681
620
  Publish a message on pubsub channel.
Binary file
glide/glide_client.py CHANGED
@@ -338,7 +338,7 @@ class BaseClient(CoreCommands):
338
338
  request.callback_idx if isinstance(request, CommandRequest) else 0
339
339
  )
340
340
  res_future = self._available_futures.pop(callback_idx, None)
341
- if res_future:
341
+ if res_future and not res_future.done():
342
342
  res_future.set_exception(e)
343
343
  else:
344
344
  ClientLogger.log(
@@ -355,7 +355,10 @@ class BaseClient(CoreCommands):
355
355
  b_arr = bytearray()
356
356
  for request in requests:
357
357
  ProtobufCodec.encode_delimited(b_arr, request)
358
- await self._stream.send(b_arr)
358
+ try:
359
+ await self._stream.send(b_arr)
360
+ except (anyio.ClosedResourceError, anyio.EndOfStream):
361
+ raise ClosingError("The communication layer was unexpectedly closed.")
359
362
 
360
363
  def _encode_arg(self, arg: TEncodable) -> bytes:
361
364
  """
@@ -403,6 +403,27 @@ class BaseBatch:
403
403
  """
404
404
  return self.append_command(RequestType.ConfigResetStat, [])
405
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
+
406
427
  def mset(self: TBatch, key_value_map: Mapping[TEncodable, TEncodable]) -> TBatch:
407
428
  """
408
429
  Set multiple keys to multiple values in a single atomic operation.
@@ -5754,25 +5775,6 @@ class Batch(BaseBatch):
5754
5775
 
5755
5776
  """
5756
5777
 
5757
- # TODO: add SLAVEOF and all SENTINEL commands
5758
- def move(self, key: TEncodable, db_index: int) -> "Batch":
5759
- """
5760
- Move `key` from the currently selected database to the database specified by `db_index`.
5761
-
5762
- See [valkey.io](https://valkey.io/commands/move/) for more details.
5763
-
5764
- Args:
5765
- key (TEncodable): The key to move.
5766
- db_index (int): The index of the database to move `key` to.
5767
-
5768
- Commands response:
5769
- bool: True if `key` was moved.
5770
-
5771
- False if the `key` already exists in the destination database
5772
- or does not exist in the source database.
5773
- """
5774
- return self.append_command(RequestType.Move, [key, str(db_index)])
5775
-
5776
5778
  def select(self, index: int) -> "Batch":
5777
5779
  """
5778
5780
  Change the currently selected database.
@@ -5883,7 +5885,11 @@ class ClusterBatch(BaseBatch):
5883
5885
  self,
5884
5886
  source: TEncodable,
5885
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
5886
5891
  replace: Optional[bool] = None,
5892
+ destinationDB: Optional[int] = None,
5887
5893
  ) -> "ClusterBatch":
5888
5894
  """
5889
5895
  Copies the value stored at the `source` to the `destination` key. When `replace` is True,
@@ -5895,15 +5901,17 @@ class ClusterBatch(BaseBatch):
5895
5901
  source (TEncodable): The key to the source value.
5896
5902
  destination (TEncodable): The key where the value should be copied to.
5897
5903
  replace (Optional[bool]): If the destination key should be removed before copying the value to it.
5898
-
5904
+ destinationDB (Optional[int]): The alternative logical database index for the destination key.
5899
5905
  Command response:
5900
5906
  bool: True if the source was copied.
5901
5907
 
5902
5908
  Otherwise, return False.
5903
5909
 
5904
- Since: Valkey version 6.2.0.
5910
+ Since: Valkey version 9.0.0.
5905
5911
  """
5906
5912
  args = [source, destination]
5913
+ if destinationDB is not None:
5914
+ args.extend(["DB", str(destinationDB)])
5907
5915
  if replace is not None:
5908
5916
  args.append("REPLACE")
5909
5917
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: valkey-glide
3
- Version: 2.1.0rc8
3
+ Version: 2.1.1
4
4
  Classifier: Topic :: Database
5
5
  Classifier: Topic :: Utilities
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -1,19 +1,19 @@
1
- valkey_glide-2.1.0rc8.dist-info/METADATA,sha256=nGnpNUXwxxlbh61Lt021I1CPMWM_W5U2Nzf0pLGkNss,6978
2
- valkey_glide-2.1.0rc8.dist-info/WHEEL,sha256=WKnnnV-Uggn89gY5LlN93bk9B3X9JgieltY0v0WQhvw,107
1
+ valkey_glide-2.1.1.dist-info/METADATA,sha256=EshK3v6Is9vHcZr7h2IDeuf8axqHviesNEduFqXtYUo,6975
2
+ valkey_glide-2.1.1.dist-info/WHEEL,sha256=WKnnnV-Uggn89gY5LlN93bk9B3X9JgieltY0v0WQhvw,107
3
3
  glide/async_commands/glide_json.py,sha256=H5dnB4vJkGPpNXJZhhVyPQoTSbkN_chq5Xw6tkP0wMQ,60410
4
4
  glide/async_commands/ft.py,sha256=1v96sBCgiXtPbj85ZurY3ruLCmok3cPoaIXSiJBEv9Y,16849
5
5
  glide/async_commands/__init__.py,sha256=_tbTAFATlzp4L2qe-H77PpAQK-16VsV-y7uKNUKLC_o,136
6
- glide/async_commands/core.py,sha256=csbFWNGqduOgFsL378LYynLqHZURAYoewdKmmsrFsTs,328186
7
- glide/async_commands/standalone_commands.py,sha256=6oPesnC8WK816JbBySUZ9dSXPbdtN0dvd8rRde646NQ,40364
8
- glide/async_commands/cluster_commands.py,sha256=Lji6eo2LaoXwy4Ha3e6bcGOHyMQHdDBiSQLt1kf9gGo,60129
9
- glide/__init__.py,sha256=r0VyTcuIdVzXTTZW6TmWwCsTCIg54ciyba1iDM8PFVQ,7055
6
+ glide/async_commands/core.py,sha256=K-aEjJqzfCNRLzm_DhFWCGgoEy6SggG-6EL5rsGtvEc,329613
7
+ glide/async_commands/standalone_commands.py,sha256=Io98Ebd96xXbw4DYoDJcKxTpxcaMteQ8sxeaTv0UuDk,38228
8
+ glide/async_commands/cluster_commands.py,sha256=NCjgDTHPBbqoa7M5lOeEDiFVGMhYqJyvMEV3TiPz8kU,61045
9
+ glide/__init__.py,sha256=6FuOMIsm52UiKxJsb2dUj06vwCT8DOsxZDqxMx8d6vQ,8767
10
10
  glide/glide.pyi,sha256=6JIpAeADQ-1fU1Mp99pyh7aJORDxAAdtQebV5aByIVI,2093
11
11
  glide/opentelemetry.py,sha256=vg9fTYXj7_rni7hVBkZBJ1ZN4-RSGde5fOH4DsnVx_4,7476
12
- glide/glide_client.py,sha256=4RKpPvaci7XmlFgoI5s__P3dATk8sM2QcpUBFnFVq78,32405
12
+ glide/glide_client.py,sha256=lIxvEkMsUG6Ura42dDrFbP8OPYJ1bXk-LsFf4eN5fwo,32594
13
13
  glide/logger.py,sha256=5-bAhfH_6hYEXdcgBR9R_wdeffSLHqEN-aQeIyMHnYY,4103
14
14
  glide_shared/__init__.py,sha256=Jgl61tWsX5n1F1a5_rxPvWBuMkBYtJ7gCLFRDPwGV8o,7141
15
15
  glide_shared/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- glide_shared/commands/batch.py,sha256=HxvswR5epj2A9nx-i69xzlO0L3jRWQNAfOg9pmmg3dE,246833
16
+ glide_shared/commands/batch.py,sha256=Ji-Ljo0lgd_9jcwVfklNns8Crfqavtlgb33k_8Duj8g,247356
17
17
  glide_shared/commands/batch_options.py,sha256=i2lDCLhMzUvpArb2bxX16xu7X-im0hLPaLXALkxWeQ8,11130
18
18
  glide_shared/commands/bitmap.py,sha256=ZHGLcKBP7RADtANqIR7PWdIW_gfDBFgpkIsQ-T4QFBQ,10125
19
19
  glide_shared/commands/command_args.py,sha256=55vpSxeQr8wFU7olkFTEecl66wPk1g6vWxVYj16UvXs,2529
@@ -35,5 +35,5 @@ glide_shared/protobuf/connection_request_pb2.py,sha256=b3jDmMetSHUrZGmQd8b5DooZZ
35
35
  glide_shared/protobuf/response_pb2.py,sha256=oT2GHUwjrxvBVdINRKCvb3_BFN0Fq2wqwHbTj7KAX2E,2110
36
36
  glide_shared/protobuf_codec.py,sha256=xwt4-D4WbvNIY_vjOd-00c73HOyNjWq7nN-Z718PBVA,3667
37
37
  glide_shared/routes.py,sha256=HFccxCzXQXSi6Y1HFsRUm9ZcbJgCrar6y6uOWpGJWe0,4746
38
- glide/glide.cpython-313-darwin.so,sha256=mn6aCJpZM-AgE08SQYuzV0kGGVHOEiGOsqzYddGIZaI,11432576
39
- valkey_glide-2.1.0rc8.dist-info/RECORD,,
38
+ glide/glide.cpython-313-darwin.so,sha256=WCVVGFY5OmZdCLRRPcJC42P1RNM_-Mvr-qGAJDon5rY,11342936
39
+ valkey_glide-2.1.1.dist-info/RECORD,,