coredis 5.1.0__py3-none-any.whl → 5.2.0__py3-none-any.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 coredis might be problematic. Click here for more details.
- coredis/__init__.py +2 -6
- coredis/_enum.py +42 -0
- coredis/_utils.py +279 -319
- coredis/_version.py +29 -16
- coredis/_version.pyi +1 -0
- coredis/client/basic.py +11 -2
- coredis/commands/_key_spec.py +2 -0
- coredis/commands/constants.py +5 -1
- coredis/commands/core.py +87 -3
- coredis/commands/monitor.py +1 -0
- coredis/commands/pubsub.py +2 -1
- coredis/tokens.py +122 -54
- {coredis-5.1.0.dist-info → coredis-5.2.0.dist-info}/METADATA +13 -31
- {coredis-5.1.0.dist-info → coredis-5.2.0.dist-info}/RECORD +16 -16
- {coredis-5.1.0.dist-info → coredis-5.2.0.dist-info}/WHEEL +1 -2
- coredis/speedups.pyi +0 -4
- coredis-5.1.0.dist-info/top_level.txt +0 -1
- {coredis-5.1.0.dist-info → coredis-5.2.0.dist-info}/licenses/LICENSE +0 -0
coredis/__init__.py
CHANGED
|
@@ -8,8 +8,7 @@ cluster & sentinel.
|
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
-
from
|
|
12
|
-
|
|
11
|
+
from coredis._version import __version__
|
|
13
12
|
from coredis.client import Redis, RedisCluster
|
|
14
13
|
from coredis.config import Config
|
|
15
14
|
from coredis.connection import (
|
|
@@ -26,8 +25,6 @@ from coredis.pool import (
|
|
|
26
25
|
)
|
|
27
26
|
from coredis.tokens import PureToken
|
|
28
27
|
|
|
29
|
-
from . import _version
|
|
30
|
-
|
|
31
28
|
__all__ = [
|
|
32
29
|
"Config",
|
|
33
30
|
"Redis",
|
|
@@ -41,6 +38,5 @@ __all__ = [
|
|
|
41
38
|
"BlockingClusterConnectionPool",
|
|
42
39
|
"ClusterConnectionPool",
|
|
43
40
|
"PureToken",
|
|
41
|
+
"__version__",
|
|
44
42
|
]
|
|
45
|
-
|
|
46
|
-
__version__ = cast(str, _version.get_versions()["version"]) # type: ignore
|
coredis/_enum.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
|
|
5
|
+
from coredis.typing import StringT
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@enum.unique
|
|
9
|
+
class CaseAndEncodingInsensitiveEnum(bytes, enum.Enum):
|
|
10
|
+
__decoded: set[StringT]
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def variants(self) -> set[StringT]:
|
|
14
|
+
if not hasattr(self, "__decoded"):
|
|
15
|
+
decoded = str(self)
|
|
16
|
+
self.__decoded = {
|
|
17
|
+
self.value.lower(), # type: ignore
|
|
18
|
+
self.value, # type: ignore
|
|
19
|
+
decoded.lower(),
|
|
20
|
+
decoded.upper(),
|
|
21
|
+
}
|
|
22
|
+
return self.__decoded
|
|
23
|
+
|
|
24
|
+
def __eq__(self, other: object) -> bool:
|
|
25
|
+
"""
|
|
26
|
+
Since redis tokens are case insensitive allow mixed case
|
|
27
|
+
Additionally allow strings to be passed in instead of
|
|
28
|
+
bytes.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
if other:
|
|
32
|
+
if isinstance(other, self.__class__):
|
|
33
|
+
return bool(self.value == other.value)
|
|
34
|
+
else:
|
|
35
|
+
return other in self.variants
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
def __str__(self) -> str:
|
|
39
|
+
return self.decode("latin-1")
|
|
40
|
+
|
|
41
|
+
def __hash__(self) -> int:
|
|
42
|
+
return hash(self.value)
|
coredis/_utils.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import enum
|
|
4
3
|
from collections import UserDict
|
|
5
4
|
from typing import Any
|
|
6
5
|
|
|
@@ -81,43 +80,6 @@ class EncodingInsensitiveDict(UserDict[Any, Any]):
|
|
|
81
80
|
return d
|
|
82
81
|
|
|
83
82
|
|
|
84
|
-
@enum.unique
|
|
85
|
-
class CaseAndEncodingInsensitiveEnum(bytes, enum.Enum):
|
|
86
|
-
__decoded: set[StringT]
|
|
87
|
-
|
|
88
|
-
@property
|
|
89
|
-
def variants(self) -> set[StringT]:
|
|
90
|
-
if not hasattr(self, "__decoded"):
|
|
91
|
-
decoded = str(self)
|
|
92
|
-
self.__decoded = {
|
|
93
|
-
self.value.lower(), # type: ignore
|
|
94
|
-
self.value, # type: ignore
|
|
95
|
-
decoded.lower(),
|
|
96
|
-
decoded.upper(),
|
|
97
|
-
}
|
|
98
|
-
return self.__decoded
|
|
99
|
-
|
|
100
|
-
def __eq__(self, other: object) -> bool:
|
|
101
|
-
"""
|
|
102
|
-
Since redis tokens are case insensitive allow mixed case
|
|
103
|
-
Additionally allow strings to be passed in instead of
|
|
104
|
-
bytes.
|
|
105
|
-
"""
|
|
106
|
-
|
|
107
|
-
if other:
|
|
108
|
-
if isinstance(other, self.__class__):
|
|
109
|
-
return bool(self.value == other.value)
|
|
110
|
-
else:
|
|
111
|
-
return other in self.variants
|
|
112
|
-
return False
|
|
113
|
-
|
|
114
|
-
def __str__(self) -> str:
|
|
115
|
-
return self.decode("latin-1")
|
|
116
|
-
|
|
117
|
-
def __hash__(self) -> int:
|
|
118
|
-
return hash(self.value)
|
|
119
|
-
|
|
120
|
-
|
|
121
83
|
def b(x: ResponseType, encoding: str | None = None) -> bytes:
|
|
122
84
|
if isinstance(x, bytes):
|
|
123
85
|
return x
|
|
@@ -191,290 +153,288 @@ def query_param_to_bool(value: Any | None) -> bool | None:
|
|
|
191
153
|
|
|
192
154
|
# ++++++++++ cluster utils ++++++++++++++
|
|
193
155
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
return crc16(key) % 16384
|
|
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
|
|
474
435
|
|
|
475
436
|
|
|
476
437
|
__all__ = [
|
|
477
438
|
"hash_slot",
|
|
478
439
|
"EncodingInsensitiveDict",
|
|
479
|
-
"CaseAndEncodingInsensitiveEnum",
|
|
480
440
|
]
|