valkey-glide 2.1.0rc9__cp39-cp39-macosx_11_0_arm64.whl → 2.1.1rc3__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.

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",
@@ -1062,39 +1062,70 @@ class ClusterCommands(CoreCommands):
1062
1062
  await self._execute_command(RequestType.FlushDB, args, route),
1063
1063
  )
1064
1064
 
1065
- async def copy(
1066
- self,
1067
- source: TEncodable,
1068
- destination: TEncodable,
1069
- replace: Optional[bool] = None,
1070
- ) -> bool:
1071
1065
  """
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.
1066
+ Copies the value stored at the `source` to the `destination` key. If `destinationDB`
1067
+ is specified, the value will be copied to the database specified by `destinationDB`,
1068
+ otherwise the current database will be used. When `replace` is True, removes the
1069
+ `destination` key first if it already exists, otherwise performs no action.
1074
1070
 
1075
1071
  See [valkey.io](https://valkey.io/commands/copy) for more details.
1076
1072
 
1077
- Note:
1078
- Both `source` and `destination` must map to the same hash slot.
1079
-
1080
1073
  Args:
1081
1074
  source (TEncodable): The key to the source value.
1082
1075
  destination (TEncodable): The key where the value should be copied to.
1076
+ destinationDB (Optional[Union[int, str]]): The alternative logical database index for the destination key.
1083
1077
  replace (Optional[bool]): If the destination key should be removed before copying the value to it.
1084
1078
 
1085
1079
  Returns:
1086
- bool: True if the source was copied. Otherwise, returns False.
1080
+ bool: True if the source was copied. Otherwise, return False.
1087
1081
 
1088
1082
  Examples:
1089
1083
  >>> await client.set("source", "sheep")
1090
- >>> await client.copy(b"source", b"destination")
1091
- True # Source was copied
1084
+ >>> await client.copy(b"source", b"destination", destinationDB=1)
1085
+ True # Source was copied to DB 1
1086
+ >>> await client.select(1)
1092
1087
  >>> await client.get("destination")
1093
1088
  b"sheep"
1094
1089
 
1095
- Since: Valkey version 6.2.0.
1090
+ Since: Valkey version 9.0.0.
1091
+ """
1092
+ ...
1093
+
1094
+ async def copy(
1095
+ self,
1096
+ source: TEncodable,
1097
+ destination: TEncodable,
1098
+ # TODO next major release the arguments replace and destinationDB must have their order
1099
+ # swapped to align with the standalone order.
1100
+ # At the moment of the patch release 2.1.1. we can't have a breaking change
1101
+ replace: Optional[bool] = None,
1102
+ destinationDB: Optional[int] = None,
1103
+ ) -> bool:
1104
+ """
1105
+ Copies the value stored at the `source` to the `destination` key.
1106
+
1107
+ This method supports two signatures:
1108
+ 1. copy(source, destination, replace=None) - original API
1109
+ 2. copy(source, destination, replace=None, destinationDB=None) - new API with DB support
1110
+
1111
+ When `replace` is True, removes the `destination` key first if it already exists,
1112
+ otherwise performs no action.
1113
+
1114
+ See [valkey.io](https://valkey.io/commands/copy) for more details.
1115
+
1116
+ Note:
1117
+ When `destinationDB` is not provided, both `source` and `destination` must map to the same hash slot.
1096
1118
  """
1119
+ # Handle backward compatibility for positional arguments
1120
+ # If destinationDB is a boolean, it's likely the old API: copy(source, destination, replace)
1121
+ if isinstance(destinationDB, bool):
1122
+ replace = destinationDB
1123
+ destinationDB = None
1124
+
1125
+ # Build command arguments
1097
1126
  args: List[TEncodable] = [source, destination]
1127
+ if destinationDB is not None:
1128
+ args.extend(["DB", str(destinationDB)])
1098
1129
  if replace is True:
1099
1130
  args.append("REPLACE")
1100
1131
  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.0rc9
3
+ Version: 2.1.1rc3
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.0rc9.dist-info/METADATA,sha256=WIAt07af8SjYV7rA0_el-wtnYcaT0yluKGnLDFWPyaA,6978
2
- valkey_glide-2.1.0rc9.dist-info/WHEEL,sha256=SjFvs0za84r93yXv_seM90QIJLVMin7Qs7nbzy5Blh4,104
1
+ valkey_glide-2.1.1rc3.dist-info/METADATA,sha256=hlIous9dfGwwLPBIdYtJZABbkyDd3OwFyQ398V3a-gw,6978
2
+ valkey_glide-2.1.1rc3.dist-info/WHEEL,sha256=SjFvs0za84r93yXv_seM90QIJLVMin7Qs7nbzy5Blh4,104
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=y1Viyz-TpatVu1wPzEmBJsifJWUhHotQrUGDWwYoOI8,61722
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-39-darwin.so,sha256=eQeuVGnhFlWE-FeyuYPyCaXTNfJKmNVEgp6xK_djV2k,9891664
39
- valkey_glide-2.1.0rc9.dist-info/RECORD,,
38
+ glide/glide.cpython-39-darwin.so,sha256=OFo7SJnf5iuTsq_HdiINBFWyKBxRIhFeN0dbxkcuUbk,9891712
39
+ valkey_glide-2.1.1rc3.dist-info/RECORD,,