coredis 5.5.0__cp314-cp314-macosx_10_13_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.
Files changed (100) hide show
  1. 22fe76227e35f92ab5c3__mypyc.cpython-314-darwin.so +0 -0
  2. coredis/__init__.py +42 -0
  3. coredis/_enum.py +42 -0
  4. coredis/_json.py +11 -0
  5. coredis/_packer.cpython-314-darwin.so +0 -0
  6. coredis/_packer.py +71 -0
  7. coredis/_protocols.py +50 -0
  8. coredis/_py_311_typing.py +20 -0
  9. coredis/_py_312_typing.py +17 -0
  10. coredis/_sidecar.py +114 -0
  11. coredis/_utils.cpython-314-darwin.so +0 -0
  12. coredis/_utils.py +440 -0
  13. coredis/_version.py +34 -0
  14. coredis/_version.pyi +1 -0
  15. coredis/cache.py +801 -0
  16. coredis/client/__init__.py +6 -0
  17. coredis/client/basic.py +1240 -0
  18. coredis/client/cluster.py +1265 -0
  19. coredis/commands/__init__.py +64 -0
  20. coredis/commands/_key_spec.py +517 -0
  21. coredis/commands/_utils.py +108 -0
  22. coredis/commands/_validators.py +159 -0
  23. coredis/commands/_wrappers.py +175 -0
  24. coredis/commands/bitfield.py +110 -0
  25. coredis/commands/constants.py +662 -0
  26. coredis/commands/core.py +8484 -0
  27. coredis/commands/function.py +408 -0
  28. coredis/commands/monitor.py +168 -0
  29. coredis/commands/pubsub.py +905 -0
  30. coredis/commands/request.py +108 -0
  31. coredis/commands/script.py +296 -0
  32. coredis/commands/sentinel.py +246 -0
  33. coredis/config.py +50 -0
  34. coredis/connection.py +906 -0
  35. coredis/constants.cpython-314-darwin.so +0 -0
  36. coredis/constants.py +37 -0
  37. coredis/credentials.py +45 -0
  38. coredis/exceptions.py +360 -0
  39. coredis/experimental/__init__.py +1 -0
  40. coredis/globals.py +23 -0
  41. coredis/modules/__init__.py +121 -0
  42. coredis/modules/autocomplete.py +138 -0
  43. coredis/modules/base.py +262 -0
  44. coredis/modules/filters.py +1319 -0
  45. coredis/modules/graph.py +362 -0
  46. coredis/modules/json.py +691 -0
  47. coredis/modules/response/__init__.py +0 -0
  48. coredis/modules/response/_callbacks/__init__.py +0 -0
  49. coredis/modules/response/_callbacks/autocomplete.py +42 -0
  50. coredis/modules/response/_callbacks/graph.py +237 -0
  51. coredis/modules/response/_callbacks/json.py +21 -0
  52. coredis/modules/response/_callbacks/search.py +221 -0
  53. coredis/modules/response/_callbacks/timeseries.py +158 -0
  54. coredis/modules/response/types.py +179 -0
  55. coredis/modules/search.py +1089 -0
  56. coredis/modules/timeseries.py +1139 -0
  57. coredis/parser.cpython-314-darwin.so +0 -0
  58. coredis/parser.py +344 -0
  59. coredis/pipeline.py +1225 -0
  60. coredis/pool/__init__.py +11 -0
  61. coredis/pool/basic.py +453 -0
  62. coredis/pool/cluster.py +517 -0
  63. coredis/pool/nodemanager.py +340 -0
  64. coredis/py.typed +0 -0
  65. coredis/recipes/__init__.py +0 -0
  66. coredis/recipes/credentials/__init__.py +5 -0
  67. coredis/recipes/credentials/iam_provider.py +63 -0
  68. coredis/recipes/locks/__init__.py +5 -0
  69. coredis/recipes/locks/extend.lua +17 -0
  70. coredis/recipes/locks/lua_lock.py +281 -0
  71. coredis/recipes/locks/release.lua +10 -0
  72. coredis/response/__init__.py +5 -0
  73. coredis/response/_callbacks/__init__.py +538 -0
  74. coredis/response/_callbacks/acl.py +32 -0
  75. coredis/response/_callbacks/cluster.py +183 -0
  76. coredis/response/_callbacks/command.py +86 -0
  77. coredis/response/_callbacks/connection.py +31 -0
  78. coredis/response/_callbacks/geo.py +58 -0
  79. coredis/response/_callbacks/hash.py +85 -0
  80. coredis/response/_callbacks/keys.py +59 -0
  81. coredis/response/_callbacks/module.py +33 -0
  82. coredis/response/_callbacks/script.py +85 -0
  83. coredis/response/_callbacks/sentinel.py +179 -0
  84. coredis/response/_callbacks/server.py +241 -0
  85. coredis/response/_callbacks/sets.py +44 -0
  86. coredis/response/_callbacks/sorted_set.py +204 -0
  87. coredis/response/_callbacks/streams.py +185 -0
  88. coredis/response/_callbacks/strings.py +70 -0
  89. coredis/response/_callbacks/vector_sets.py +159 -0
  90. coredis/response/_utils.py +33 -0
  91. coredis/response/types.py +416 -0
  92. coredis/retry.py +233 -0
  93. coredis/sentinel.py +477 -0
  94. coredis/stream.py +369 -0
  95. coredis/tokens.py +2286 -0
  96. coredis/typing.py +593 -0
  97. coredis-5.5.0.dist-info/METADATA +211 -0
  98. coredis-5.5.0.dist-info/RECORD +100 -0
  99. coredis-5.5.0.dist-info/WHEEL +6 -0
  100. coredis-5.5.0.dist-info/licenses/LICENSE +23 -0
coredis/_utils.py ADDED
@@ -0,0 +1,440 @@
1
+ from __future__ import annotations
2
+
3
+ from collections import UserDict
4
+ from typing import Any
5
+
6
+ from coredis.typing import (
7
+ Hashable,
8
+ Iterable,
9
+ Mapping,
10
+ MutableMapping,
11
+ ResponseType,
12
+ StringT,
13
+ TypeVar,
14
+ )
15
+
16
+ T = TypeVar("T")
17
+ U = TypeVar("U")
18
+
19
+
20
+ class EncodingInsensitiveDict(UserDict[Any, Any]):
21
+ def __init__(
22
+ self,
23
+ initial: MutableMapping[Any, Any] | None = None,
24
+ encoding: str = "utf-8",
25
+ ):
26
+ self._encoding = encoding
27
+ super().__init__(initial or {})
28
+
29
+ def _alt_key(self, key: StringT) -> StringT:
30
+ if isinstance(key, str):
31
+ try:
32
+ byte_alt = key.encode(self._encoding)
33
+ if byte_alt in self.data:
34
+ return byte_alt
35
+ except UnicodeEncodeError:
36
+ pass
37
+ elif isinstance(key, bytes):
38
+ try:
39
+ str_alt = key.decode(self._encoding)
40
+ if str_alt in self.data:
41
+ return str_alt
42
+ except UnicodeDecodeError:
43
+ pass
44
+ return key
45
+
46
+ def __getitem__(self, key: StringT) -> Any:
47
+ if key in self.data:
48
+ return self.data[key]
49
+ alt = self._alt_key(key)
50
+ if alt in self.data:
51
+ return self.data[alt]
52
+ raise KeyError(key)
53
+
54
+ def __setitem__(self, key: StringT, value: Any) -> None:
55
+ alt = self._alt_key(key)
56
+ self.data[alt] = value
57
+
58
+ def __delitem__(self, key: StringT) -> None:
59
+ alt = self._alt_key(key)
60
+ del self.data[alt]
61
+
62
+ def __contains__(self, key: Any) -> bool:
63
+ return key in self.data or self._alt_key(key) in self.data
64
+
65
+ def get(self, key: StringT, default: Any = None) -> Any:
66
+ return self.data.get(key, self.data.get(self._alt_key(key), default))
67
+
68
+ def pop(self, key: StringT, default: Any = None) -> Any:
69
+ if key in self.data:
70
+ return self.data.pop(key)
71
+ alt = self._alt_key(key)
72
+ return self.data.pop(alt, default)
73
+
74
+ def stringify_keys(self) -> dict[str, Any]:
75
+ d = {}
76
+ for key, value in self.items():
77
+ d[key.decode(self._encoding) if isinstance(key, bytes) else key] = (
78
+ value.stringify_keys() if isinstance(value, EncodingInsensitiveDict) else value
79
+ )
80
+ return d
81
+
82
+
83
+ def b(x: ResponseType, encoding: str | None = None) -> bytes:
84
+ if isinstance(x, bytes):
85
+ return x
86
+ if not isinstance(x, str):
87
+ _v = str(x)
88
+ else:
89
+ _v = x
90
+ return _v.encode(encoding) if encoding else _v.encode()
91
+
92
+
93
+ def nativestr(x: ResponseType, encoding: str = "utf-8") -> str:
94
+ if isinstance(x, (str, bytes)):
95
+ return x if isinstance(x, str) else x.decode(encoding, "replace")
96
+ elif isinstance(x, (int, float, bool)):
97
+ return str(x)
98
+ raise ValueError(f"Unable to cast {x} to string")
99
+
100
+
101
+ def tuples_to_flat_list(nested_list: Iterable[tuple[T, ...]]) -> list[T]:
102
+ return [item for sublist in nested_list for item in sublist]
103
+
104
+
105
+ def dict_to_flat_list(mapping: Mapping[T, U], reverse: bool = False) -> list[T | U]:
106
+ e1: list[T | U] = list(mapping.keys())
107
+ e2: list[T | U] = list(mapping.values())
108
+
109
+ ret: list[T | U] = []
110
+
111
+ if reverse:
112
+ e1, e2 = e2, e1
113
+
114
+ for idx, e in enumerate(e1):
115
+ ret.append(e)
116
+ ret.append(e2[idx])
117
+
118
+ return ret
119
+
120
+
121
+ def make_hashable(*args: Any) -> tuple[Hashable, ...]:
122
+ return tuple(
123
+ (
124
+ tuple(make_hashable(v)[0] for v in a)
125
+ if isinstance(a, (tuple, list))
126
+ else (
127
+ frozenset(make_hashable(v)[0] for v in a)
128
+ if isinstance(a, set)
129
+ else (
130
+ tuple((k, make_hashable(v)[0]) for k, v in a.items())
131
+ if isinstance(a, dict)
132
+ # this will fail downstream if `a` is not hashable
133
+ else a
134
+ )
135
+ )
136
+ )
137
+ for a in args
138
+ )
139
+
140
+
141
+ def query_param_to_bool(value: Any | None) -> bool | None:
142
+ if value is None or value in ("", b""):
143
+ return None
144
+ if isinstance(value, (int, float, bool, str, bytes)):
145
+ value = nativestr(value)
146
+ if value.upper() in ("0", "F", "FALSE", "N", "NO"):
147
+ return False
148
+ elif value.upper() in ("1", "T", "TRUE", "Y", "YES"):
149
+ return True
150
+
151
+ return bool(value)
152
+
153
+
154
+ # ++++++++++ cluster utils ++++++++++++++
155
+
156
+ x_mode_m_crc16_lookup = [
157
+ 0x0000,
158
+ 0x1021,
159
+ 0x2042,
160
+ 0x3063,
161
+ 0x4084,
162
+ 0x50A5,
163
+ 0x60C6,
164
+ 0x70E7,
165
+ 0x8108,
166
+ 0x9129,
167
+ 0xA14A,
168
+ 0xB16B,
169
+ 0xC18C,
170
+ 0xD1AD,
171
+ 0xE1CE,
172
+ 0xF1EF,
173
+ 0x1231,
174
+ 0x0210,
175
+ 0x3273,
176
+ 0x2252,
177
+ 0x52B5,
178
+ 0x4294,
179
+ 0x72F7,
180
+ 0x62D6,
181
+ 0x9339,
182
+ 0x8318,
183
+ 0xB37B,
184
+ 0xA35A,
185
+ 0xD3BD,
186
+ 0xC39C,
187
+ 0xF3FF,
188
+ 0xE3DE,
189
+ 0x2462,
190
+ 0x3443,
191
+ 0x0420,
192
+ 0x1401,
193
+ 0x64E6,
194
+ 0x74C7,
195
+ 0x44A4,
196
+ 0x5485,
197
+ 0xA56A,
198
+ 0xB54B,
199
+ 0x8528,
200
+ 0x9509,
201
+ 0xE5EE,
202
+ 0xF5CF,
203
+ 0xC5AC,
204
+ 0xD58D,
205
+ 0x3653,
206
+ 0x2672,
207
+ 0x1611,
208
+ 0x0630,
209
+ 0x76D7,
210
+ 0x66F6,
211
+ 0x5695,
212
+ 0x46B4,
213
+ 0xB75B,
214
+ 0xA77A,
215
+ 0x9719,
216
+ 0x8738,
217
+ 0xF7DF,
218
+ 0xE7FE,
219
+ 0xD79D,
220
+ 0xC7BC,
221
+ 0x48C4,
222
+ 0x58E5,
223
+ 0x6886,
224
+ 0x78A7,
225
+ 0x0840,
226
+ 0x1861,
227
+ 0x2802,
228
+ 0x3823,
229
+ 0xC9CC,
230
+ 0xD9ED,
231
+ 0xE98E,
232
+ 0xF9AF,
233
+ 0x8948,
234
+ 0x9969,
235
+ 0xA90A,
236
+ 0xB92B,
237
+ 0x5AF5,
238
+ 0x4AD4,
239
+ 0x7AB7,
240
+ 0x6A96,
241
+ 0x1A71,
242
+ 0x0A50,
243
+ 0x3A33,
244
+ 0x2A12,
245
+ 0xDBFD,
246
+ 0xCBDC,
247
+ 0xFBBF,
248
+ 0xEB9E,
249
+ 0x9B79,
250
+ 0x8B58,
251
+ 0xBB3B,
252
+ 0xAB1A,
253
+ 0x6CA6,
254
+ 0x7C87,
255
+ 0x4CE4,
256
+ 0x5CC5,
257
+ 0x2C22,
258
+ 0x3C03,
259
+ 0x0C60,
260
+ 0x1C41,
261
+ 0xEDAE,
262
+ 0xFD8F,
263
+ 0xCDEC,
264
+ 0xDDCD,
265
+ 0xAD2A,
266
+ 0xBD0B,
267
+ 0x8D68,
268
+ 0x9D49,
269
+ 0x7E97,
270
+ 0x6EB6,
271
+ 0x5ED5,
272
+ 0x4EF4,
273
+ 0x3E13,
274
+ 0x2E32,
275
+ 0x1E51,
276
+ 0x0E70,
277
+ 0xFF9F,
278
+ 0xEFBE,
279
+ 0xDFDD,
280
+ 0xCFFC,
281
+ 0xBF1B,
282
+ 0xAF3A,
283
+ 0x9F59,
284
+ 0x8F78,
285
+ 0x9188,
286
+ 0x81A9,
287
+ 0xB1CA,
288
+ 0xA1EB,
289
+ 0xD10C,
290
+ 0xC12D,
291
+ 0xF14E,
292
+ 0xE16F,
293
+ 0x1080,
294
+ 0x00A1,
295
+ 0x30C2,
296
+ 0x20E3,
297
+ 0x5004,
298
+ 0x4025,
299
+ 0x7046,
300
+ 0x6067,
301
+ 0x83B9,
302
+ 0x9398,
303
+ 0xA3FB,
304
+ 0xB3DA,
305
+ 0xC33D,
306
+ 0xD31C,
307
+ 0xE37F,
308
+ 0xF35E,
309
+ 0x02B1,
310
+ 0x1290,
311
+ 0x22F3,
312
+ 0x32D2,
313
+ 0x4235,
314
+ 0x5214,
315
+ 0x6277,
316
+ 0x7256,
317
+ 0xB5EA,
318
+ 0xA5CB,
319
+ 0x95A8,
320
+ 0x8589,
321
+ 0xF56E,
322
+ 0xE54F,
323
+ 0xD52C,
324
+ 0xC50D,
325
+ 0x34E2,
326
+ 0x24C3,
327
+ 0x14A0,
328
+ 0x0481,
329
+ 0x7466,
330
+ 0x6447,
331
+ 0x5424,
332
+ 0x4405,
333
+ 0xA7DB,
334
+ 0xB7FA,
335
+ 0x8799,
336
+ 0x97B8,
337
+ 0xE75F,
338
+ 0xF77E,
339
+ 0xC71D,
340
+ 0xD73C,
341
+ 0x26D3,
342
+ 0x36F2,
343
+ 0x0691,
344
+ 0x16B0,
345
+ 0x6657,
346
+ 0x7676,
347
+ 0x4615,
348
+ 0x5634,
349
+ 0xD94C,
350
+ 0xC96D,
351
+ 0xF90E,
352
+ 0xE92F,
353
+ 0x99C8,
354
+ 0x89E9,
355
+ 0xB98A,
356
+ 0xA9AB,
357
+ 0x5844,
358
+ 0x4865,
359
+ 0x7806,
360
+ 0x6827,
361
+ 0x18C0,
362
+ 0x08E1,
363
+ 0x3882,
364
+ 0x28A3,
365
+ 0xCB7D,
366
+ 0xDB5C,
367
+ 0xEB3F,
368
+ 0xFB1E,
369
+ 0x8BF9,
370
+ 0x9BD8,
371
+ 0xABBB,
372
+ 0xBB9A,
373
+ 0x4A75,
374
+ 0x5A54,
375
+ 0x6A37,
376
+ 0x7A16,
377
+ 0x0AF1,
378
+ 0x1AD0,
379
+ 0x2AB3,
380
+ 0x3A92,
381
+ 0xFD2E,
382
+ 0xED0F,
383
+ 0xDD6C,
384
+ 0xCD4D,
385
+ 0xBDAA,
386
+ 0xAD8B,
387
+ 0x9DE8,
388
+ 0x8DC9,
389
+ 0x7C26,
390
+ 0x6C07,
391
+ 0x5C64,
392
+ 0x4C45,
393
+ 0x3CA2,
394
+ 0x2C83,
395
+ 0x1CE0,
396
+ 0x0CC1,
397
+ 0xEF1F,
398
+ 0xFF3E,
399
+ 0xCF5D,
400
+ 0xDF7C,
401
+ 0xAF9B,
402
+ 0xBFBA,
403
+ 0x8FD9,
404
+ 0x9FF8,
405
+ 0x6E17,
406
+ 0x7E36,
407
+ 0x4E55,
408
+ 0x5E74,
409
+ 0x2E93,
410
+ 0x3EB2,
411
+ 0x0ED1,
412
+ 0x1EF0,
413
+ ]
414
+
415
+
416
+ def crc16(data: bytes) -> int:
417
+ crc = 0
418
+
419
+ for byte in data:
420
+ crc = ((crc << 8) & 0xFF00) ^ x_mode_m_crc16_lookup[((crc >> 8) & 0xFF) ^ byte]
421
+
422
+ return crc & 0xFFFF
423
+
424
+
425
+ def hash_slot(key: bytes) -> int:
426
+ start = key.find(b"{")
427
+
428
+ if start > -1:
429
+ end = key.find(b"}", start + 1)
430
+
431
+ if end > -1 and end != start + 1:
432
+ key = key[start + 1 : end]
433
+
434
+ return crc16(key) % 16384
435
+
436
+
437
+ __all__ = [
438
+ "hash_slot",
439
+ "EncodingInsensitiveDict",
440
+ ]
coredis/_version.py ADDED
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '5.5.0'
32
+ __version_tuple__ = version_tuple = (5, 5, 0)
33
+
34
+ __commit_id__ = commit_id = None
coredis/_version.pyi ADDED
@@ -0,0 +1 @@
1
+ __version__: str