redis-dict 3.0.0__tar.gz → 3.1.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {redis_dict-3.0.0/src/redis_dict.egg-info → redis_dict-3.1.1}/PKG-INFO +6 -3
- {redis_dict-3.0.0 → redis_dict-3.1.1}/README.md +1 -1
- {redis_dict-3.0.0 → redis_dict-3.1.1}/pyproject.toml +7 -2
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict/core.py +26 -28
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict/type_management.py +7 -4
- {redis_dict-3.0.0 → redis_dict-3.1.1/src/redis_dict.egg-info}/PKG-INFO +6 -3
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict.egg-info/requires.txt +4 -0
- {redis_dict-3.0.0 → redis_dict-3.1.1}/LICENSE +0 -0
- {redis_dict-3.0.0 → redis_dict-3.1.1}/setup.cfg +0 -0
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict/__init__.py +0 -0
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict/py.typed +0 -0
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict.egg-info/SOURCES.txt +0 -0
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict.egg-info/dependency_links.txt +0 -0
- {redis_dict-3.0.0 → redis_dict-3.1.1}/src/redis_dict.egg-info/top_level.txt +0 -0
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: redis-dict
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.1.1
|
4
4
|
Summary: Dictionary with Redis as storage backend
|
5
5
|
Author-email: Melvin Bijman <bijman.m.m@gmail.com>
|
6
6
|
License: MIT
|
7
7
|
Project-URL: Homepage, https://github.com/Attumm/redisdict
|
8
|
-
Project-URL: Documentation, https://github.
|
8
|
+
Project-URL: Documentation, https://attumm.github.io/redis-dict/
|
9
9
|
Project-URL: Repository, https://github.com/Attumm/redisdict.git
|
10
10
|
Project-URL: Changelog, https://github.com/Attumm/redisdict/releases
|
11
11
|
Keywords: redis,python,dictionary,dict,key-value,database,caching,distributed-computing,dictionary-interface,large-datasets,scientific-computing,data-persistence,high-performance,scalable,pipelining,batching,big-data,data-types,distributed-algorithms,encryption,data-management
|
@@ -64,6 +64,9 @@ Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
64
64
|
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
65
65
|
Requires-Dist: tomli; extra == "docs"
|
66
66
|
Requires-Dist: myst-parser; extra == "docs"
|
67
|
+
Provides-Extra: build
|
68
|
+
Requires-Dist: build; extra == "build"
|
69
|
+
Requires-Dist: twine; extra == "build"
|
67
70
|
|
68
71
|
# Redis-dict
|
69
72
|
[](https://pypi.org/project/redis-dict/)
|
@@ -282,7 +285,7 @@ print(dic["d"]) # Output: 4
|
|
282
285
|
```
|
283
286
|
|
284
287
|
### Additional Examples
|
285
|
-
For more advanced examples of RedisDict, please refer to the unit-test files in the repository. All features and functionalities are thoroughly tested in [unit tests (here)](https://github.com/Attumm/redis-dict/blob/main/tests.py#L1) Or take a look at load test for batching [load test](https://github.com/Attumm/redis-dict/blob/main/load_test.py#L1).
|
288
|
+
For more advanced examples of RedisDict, please refer to the unit-test files in the repository. All features and functionalities are thoroughly tested in [unit tests (here)](https://github.com/Attumm/redis-dict/blob/main/tests/unit/tests.py#L1) Or take a look at load test for batching [load test](https://github.com/Attumm/redis-dict/blob/main/tests/load/load_test.py#L1).
|
286
289
|
The unit-tests can be as used as a starting point.
|
287
290
|
|
288
291
|
## Types
|
@@ -215,7 +215,7 @@ print(dic["d"]) # Output: 4
|
|
215
215
|
```
|
216
216
|
|
217
217
|
### Additional Examples
|
218
|
-
For more advanced examples of RedisDict, please refer to the unit-test files in the repository. All features and functionalities are thoroughly tested in [unit tests (here)](https://github.com/Attumm/redis-dict/blob/main/tests.py#L1) Or take a look at load test for batching [load test](https://github.com/Attumm/redis-dict/blob/main/load_test.py#L1).
|
218
|
+
For more advanced examples of RedisDict, please refer to the unit-test files in the repository. All features and functionalities are thoroughly tested in [unit tests (here)](https://github.com/Attumm/redis-dict/blob/main/tests/unit/tests.py#L1) Or take a look at load test for batching [load test](https://github.com/Attumm/redis-dict/blob/main/tests/load/load_test.py#L1).
|
219
219
|
The unit-tests can be as used as a starting point.
|
220
220
|
|
221
221
|
## Types
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "redis-dict"
|
7
|
-
version = "3.
|
7
|
+
version = "3.1.1"
|
8
8
|
description = "Dictionary with Redis as storage backend"
|
9
9
|
authors = [
|
10
10
|
{name = "Melvin Bijman", email = "bijman.m.m@gmail.com"},
|
@@ -89,6 +89,11 @@ docs = [
|
|
89
89
|
"myst-parser",
|
90
90
|
]
|
91
91
|
|
92
|
+
build = [
|
93
|
+
"build",
|
94
|
+
"twine",
|
95
|
+
]
|
96
|
+
|
92
97
|
|
93
98
|
[tool.setuptools]
|
94
99
|
package-dir = {"" = "src"}
|
@@ -128,6 +133,6 @@ paths = ["src/redis_dict"]
|
|
128
133
|
|
129
134
|
[project.urls]
|
130
135
|
Homepage = "https://github.com/Attumm/redisdict"
|
131
|
-
Documentation = "https://github.
|
136
|
+
Documentation = "https://attumm.github.io/redis-dict/"
|
132
137
|
Repository = "https://github.com/Attumm/redisdict.git"
|
133
138
|
Changelog = "https://github.com/Attumm/redisdict/releases"
|
@@ -35,13 +35,6 @@ class RedisDict:
|
|
35
35
|
This functionality enables various use cases, such as managing encrypted data in Redis,
|
36
36
|
To implement this, simply create and register your custom encoding and decoding functions.
|
37
37
|
By delegating serialization to redis-dict, reduce complexity and have simple code in the codebase.
|
38
|
-
|
39
|
-
Attributes:
|
40
|
-
decoding_registry (Dict[str, DecodeFuncType]): Mapping of decoding transformation functions based on type
|
41
|
-
encoding_registry (Dict[str, EncodeFuncType]): Mapping of encoding transformation functions based on type
|
42
|
-
namespace (str): A string used as a prefix for Redis keys to separate data in different namespaces.
|
43
|
-
expire (Union[int, None]): An optional expiration time for keys, in seconds.
|
44
|
-
|
45
38
|
"""
|
46
39
|
|
47
40
|
encoding_registry: EncodeType = enc_reg
|
@@ -53,7 +46,8 @@ class RedisDict:
|
|
53
46
|
preserve_expiration: Optional[bool] = False,
|
54
47
|
redis: "Optional[StrictRedis[Any]]" = None,
|
55
48
|
**redis_kwargs: Any) -> None:
|
56
|
-
"""
|
49
|
+
"""
|
50
|
+
Initialize a RedisDict instance.
|
57
51
|
|
58
52
|
Init the RedisDict instance.
|
59
53
|
|
@@ -220,7 +214,8 @@ class RedisDict:
|
|
220
214
|
encoding_method_name: Optional[str] = None,
|
221
215
|
decoding_method_name: Optional[str] = None,
|
222
216
|
) -> None:
|
223
|
-
"""
|
217
|
+
"""
|
218
|
+
Extend RedisDict to support a custom type in the encode/decode mapping.
|
224
219
|
|
225
220
|
This method enables serialization of instances based on their type,
|
226
221
|
allowing for custom types, specialized storage formats, and more.
|
@@ -247,19 +242,19 @@ class RedisDict:
|
|
247
242
|
attributes of the RedisDict instance
|
248
243
|
|
249
244
|
Example:
|
250
|
-
class Person:
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
redis_dict.extends_type(Person)
|
245
|
+
>>> class Person:
|
246
|
+
... def __init__(self, name, age):
|
247
|
+
... self.name = name
|
248
|
+
... self.age = age
|
249
|
+
...
|
250
|
+
... def encode(self) -> str:
|
251
|
+
... return json.dumps(self.__dict__)
|
252
|
+
...
|
253
|
+
... @classmethod
|
254
|
+
... def decode(cls, encoded_str: str) -> 'Person':
|
255
|
+
... return cls(**json.loads(encoded_str))
|
256
|
+
...
|
257
|
+
>>> redis_dict.extends_type(Person)
|
263
258
|
|
264
259
|
Args:
|
265
260
|
class_type (type): The class `__name__` will become the key for the encoding and decoding functions.
|
@@ -409,8 +404,8 @@ class RedisDict:
|
|
409
404
|
return str(self.to_dict())
|
410
405
|
|
411
406
|
def __or__(self, other: Dict[str, Any]) -> Dict[str, Any]:
|
412
|
-
"""
|
413
|
-
|
407
|
+
"""Implement the | operator (dict union).
|
408
|
+
|
414
409
|
Returns a new dictionary with items from both dictionaries.
|
415
410
|
|
416
411
|
Args:
|
@@ -432,7 +427,8 @@ class RedisDict:
|
|
432
427
|
|
433
428
|
def __ror__(self, other: Dict[str, Any]) -> Dict[str, Any]:
|
434
429
|
"""
|
435
|
-
|
430
|
+
Implement the reverse | operator.
|
431
|
+
|
436
432
|
Called when RedisDict is on the right side of |.
|
437
433
|
|
438
434
|
Args:
|
@@ -454,7 +450,8 @@ class RedisDict:
|
|
454
450
|
|
455
451
|
def __ior__(self, other: Dict[str, Any]) -> 'RedisDict':
|
456
452
|
"""
|
457
|
-
|
453
|
+
Implement the |= operator (in-place union).
|
454
|
+
|
458
455
|
Modifies the current dictionary by adding items from other.
|
459
456
|
|
460
457
|
Args:
|
@@ -475,7 +472,7 @@ class RedisDict:
|
|
475
472
|
@classmethod
|
476
473
|
def __class_getitem__(cls: Type['RedisDict'], key: Any) -> Type['RedisDict']:
|
477
474
|
"""
|
478
|
-
|
475
|
+
Enable type hinting support like RedisDict[str, Any].
|
479
476
|
|
480
477
|
Args:
|
481
478
|
key (Any): The type parameter(s) used in the type hint.
|
@@ -487,7 +484,8 @@ class RedisDict:
|
|
487
484
|
|
488
485
|
def __reversed__(self) -> Iterator[str]:
|
489
486
|
"""
|
490
|
-
|
487
|
+
Implement reversed() built-in.
|
488
|
+
|
491
489
|
Returns an iterator over dictionary keys in reverse insertion order.
|
492
490
|
|
493
491
|
Warning:
|
@@ -143,7 +143,8 @@ encoding_registry: EncodeType = {
|
|
143
143
|
|
144
144
|
|
145
145
|
class RedisDictJSONEncoder(json.JSONEncoder):
|
146
|
-
"""
|
146
|
+
"""
|
147
|
+
Extends JSON encoding capabilities by reusing RedisDict type conversion.
|
147
148
|
|
148
149
|
Uses existing decoding_registry to know which types to handle specially and
|
149
150
|
encoding_registry (falls back to str) for converting to JSON-compatible formats.
|
@@ -157,11 +158,11 @@ class RedisDictJSONEncoder(json.JSONEncoder):
|
|
157
158
|
}
|
158
159
|
|
159
160
|
Notes:
|
160
|
-
|
161
161
|
Uses decoding_registry (containing all supported types) to check if type
|
162
162
|
needs special handling. For encoding, defaults to str() if no encoder exists
|
163
163
|
in encoding_registry.
|
164
164
|
"""
|
165
|
+
|
165
166
|
def default(self, o: Any) -> Any:
|
166
167
|
"""Overwrite default from json encoder.
|
167
168
|
|
@@ -187,13 +188,15 @@ class RedisDictJSONEncoder(json.JSONEncoder):
|
|
187
188
|
|
188
189
|
|
189
190
|
class RedisDictJSONDecoder(json.JSONDecoder):
|
190
|
-
"""
|
191
|
+
"""
|
192
|
+
JSON decoder leveraging RedisDict existing type conversion system.
|
191
193
|
|
192
194
|
Works with RedisDictJSONEncoder to reconstruct Python objects from JSON using
|
193
195
|
RedisDict decoding_registry.
|
194
196
|
|
195
197
|
Still needs work but allows for more types than without.
|
196
198
|
"""
|
199
|
+
|
197
200
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
198
201
|
"""
|
199
202
|
Overwrite the __init__ method from JSON decoder.
|
@@ -254,7 +257,7 @@ def _default_decoder(x: str) -> str:
|
|
254
257
|
|
255
258
|
def _default_encoder(x: Any) -> str:
|
256
259
|
"""
|
257
|
-
|
260
|
+
Take x and returns the result str of the object.
|
258
261
|
|
259
262
|
Args:
|
260
263
|
x (Any): The input object
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: redis-dict
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.1.1
|
4
4
|
Summary: Dictionary with Redis as storage backend
|
5
5
|
Author-email: Melvin Bijman <bijman.m.m@gmail.com>
|
6
6
|
License: MIT
|
7
7
|
Project-URL: Homepage, https://github.com/Attumm/redisdict
|
8
|
-
Project-URL: Documentation, https://github.
|
8
|
+
Project-URL: Documentation, https://attumm.github.io/redis-dict/
|
9
9
|
Project-URL: Repository, https://github.com/Attumm/redisdict.git
|
10
10
|
Project-URL: Changelog, https://github.com/Attumm/redisdict/releases
|
11
11
|
Keywords: redis,python,dictionary,dict,key-value,database,caching,distributed-computing,dictionary-interface,large-datasets,scientific-computing,data-persistence,high-performance,scalable,pipelining,batching,big-data,data-types,distributed-algorithms,encryption,data-management
|
@@ -64,6 +64,9 @@ Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
64
64
|
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
65
65
|
Requires-Dist: tomli; extra == "docs"
|
66
66
|
Requires-Dist: myst-parser; extra == "docs"
|
67
|
+
Provides-Extra: build
|
68
|
+
Requires-Dist: build; extra == "build"
|
69
|
+
Requires-Dist: twine; extra == "build"
|
67
70
|
|
68
71
|
# Redis-dict
|
69
72
|
[](https://pypi.org/project/redis-dict/)
|
@@ -282,7 +285,7 @@ print(dic["d"]) # Output: 4
|
|
282
285
|
```
|
283
286
|
|
284
287
|
### Additional Examples
|
285
|
-
For more advanced examples of RedisDict, please refer to the unit-test files in the repository. All features and functionalities are thoroughly tested in [unit tests (here)](https://github.com/Attumm/redis-dict/blob/main/tests.py#L1) Or take a look at load test for batching [load test](https://github.com/Attumm/redis-dict/blob/main/load_test.py#L1).
|
288
|
+
For more advanced examples of RedisDict, please refer to the unit-test files in the repository. All features and functionalities are thoroughly tested in [unit tests (here)](https://github.com/Attumm/redis-dict/blob/main/tests/unit/tests.py#L1) Or take a look at load test for batching [load test](https://github.com/Attumm/redis-dict/blob/main/tests/load/load_test.py#L1).
|
286
289
|
The unit-tests can be as used as a starting point.
|
287
290
|
|
288
291
|
## Types
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|