redis-dict 2.4.1__tar.gz → 2.5.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {redis dict-2.4.1 → redis dict-2.5.1}/PKG-INFO +7 -3
- {redis dict-2.4.1 → redis dict-2.5.1}/README.md +5 -2
- {redis dict-2.4.1 → redis dict-2.5.1}/redis_dict.egg-info/PKG-INFO +7 -3
- {redis dict-2.4.1 → redis dict-2.5.1}/redis_dict.py +28 -23
- {redis dict-2.4.1 → redis dict-2.5.1}/setup.py +2 -2
- {redis dict-2.4.1 → redis dict-2.5.1}/LICENSE +0 -0
- {redis dict-2.4.1 → redis dict-2.5.1}/redis_dict.egg-info/SOURCES.txt +0 -0
- {redis dict-2.4.1 → redis dict-2.5.1}/redis_dict.egg-info/dependency_links.txt +0 -0
- {redis dict-2.4.1 → redis dict-2.5.1}/redis_dict.egg-info/requires.txt +0 -0
- {redis dict-2.4.1 → redis dict-2.5.1}/redis_dict.egg-info/top_level.txt +0 -0
- {redis dict-2.4.1 → redis dict-2.5.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: redis dict
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.5.1
|
4
4
|
Summary: Dictionary with Redis as storage backend
|
5
5
|
Home-page: https://github.com/Attumm/redisdict
|
6
6
|
Author: Melvin Bijman
|
@@ -18,12 +18,14 @@ Classifier: Programming Language :: Python :: 3.8
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.9
|
19
19
|
Classifier: Programming Language :: Python :: 3.10
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
21
22
|
Description-Content-Type: text/markdown
|
22
23
|
License-File: LICENSE
|
23
24
|
Requires-Dist: redis
|
24
25
|
|
25
26
|
# Redis-dict
|
26
|
-
[](https://github.com/Attumm/redis-dict/actions/workflows/ci.yml)
|
28
|
+
[](https://codecov.io/gh/Attumm/redis-dict)
|
27
29
|
[](https://pepy.tech/project/redis-dict)
|
28
30
|
|
29
31
|
RedisDict is a Python library that provides a convenient and familiar interface for interacting with Redis as if it were a Python dictionary. This simple yet powerful library enables you to manage key-value pairs in Redis using native Python syntax. It supports various data types, including strings, integers, floats, booleans, lists, and dictionaries, and includes additional utility functions for more complex use cases.
|
@@ -128,6 +130,8 @@ with dic.pipeline():
|
|
128
130
|
You can use RedisDict for distributed computing by starting multiple RedisDict instances on different servers or instances that have access to the same Redis instance:
|
129
131
|
```python
|
130
132
|
# On server 1
|
133
|
+
from redis_dict import RedisDict
|
134
|
+
|
131
135
|
dic = RedisDict(namespace="example")
|
132
136
|
dic["foo"] = "bar"
|
133
137
|
|
@@ -227,7 +231,7 @@ print(dic["d"]) # Output: 4
|
|
227
231
|
```
|
228
232
|
|
229
233
|
### Additional Examples
|
230
|
-
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
|
234
|
+
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).
|
231
235
|
The unit-tests can be as used as a starting point.
|
232
236
|
|
233
237
|
### Redis Encryption
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Redis-dict
|
2
|
-
[](https://github.com/Attumm/redis-dict/actions/workflows/ci.yml)
|
3
|
+
[](https://codecov.io/gh/Attumm/redis-dict)
|
3
4
|
[](https://pepy.tech/project/redis-dict)
|
4
5
|
|
5
6
|
RedisDict is a Python library that provides a convenient and familiar interface for interacting with Redis as if it were a Python dictionary. This simple yet powerful library enables you to manage key-value pairs in Redis using native Python syntax. It supports various data types, including strings, integers, floats, booleans, lists, and dictionaries, and includes additional utility functions for more complex use cases.
|
@@ -104,6 +105,8 @@ with dic.pipeline():
|
|
104
105
|
You can use RedisDict for distributed computing by starting multiple RedisDict instances on different servers or instances that have access to the same Redis instance:
|
105
106
|
```python
|
106
107
|
# On server 1
|
108
|
+
from redis_dict import RedisDict
|
109
|
+
|
107
110
|
dic = RedisDict(namespace="example")
|
108
111
|
dic["foo"] = "bar"
|
109
112
|
|
@@ -203,7 +206,7 @@ print(dic["d"]) # Output: 4
|
|
203
206
|
```
|
204
207
|
|
205
208
|
### Additional Examples
|
206
|
-
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
|
209
|
+
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).
|
207
210
|
The unit-tests can be as used as a starting point.
|
208
211
|
|
209
212
|
### Redis Encryption
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: redis-dict
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.5.1
|
4
4
|
Summary: Dictionary with Redis as storage backend
|
5
5
|
Home-page: https://github.com/Attumm/redisdict
|
6
6
|
Author: Melvin Bijman
|
@@ -18,12 +18,14 @@ Classifier: Programming Language :: Python :: 3.8
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.9
|
19
19
|
Classifier: Programming Language :: Python :: 3.10
|
20
20
|
Classifier: Programming Language :: Python :: 3.11
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
21
22
|
Description-Content-Type: text/markdown
|
22
23
|
License-File: LICENSE
|
23
24
|
Requires-Dist: redis
|
24
25
|
|
25
26
|
# Redis-dict
|
26
|
-
[](https://github.com/Attumm/redis-dict/actions/workflows/ci.yml)
|
28
|
+
[](https://codecov.io/gh/Attumm/redis-dict)
|
27
29
|
[](https://pepy.tech/project/redis-dict)
|
28
30
|
|
29
31
|
RedisDict is a Python library that provides a convenient and familiar interface for interacting with Redis as if it were a Python dictionary. This simple yet powerful library enables you to manage key-value pairs in Redis using native Python syntax. It supports various data types, including strings, integers, floats, booleans, lists, and dictionaries, and includes additional utility functions for more complex use cases.
|
@@ -128,6 +130,8 @@ with dic.pipeline():
|
|
128
130
|
You can use RedisDict for distributed computing by starting multiple RedisDict instances on different servers or instances that have access to the same Redis instance:
|
129
131
|
```python
|
130
132
|
# On server 1
|
133
|
+
from redis_dict import RedisDict
|
134
|
+
|
131
135
|
dic = RedisDict(namespace="example")
|
132
136
|
dic["foo"] = "bar"
|
133
137
|
|
@@ -227,7 +231,7 @@ print(dic["d"]) # Output: 4
|
|
227
231
|
```
|
228
232
|
|
229
233
|
### Additional Examples
|
230
|
-
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
|
234
|
+
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).
|
231
235
|
The unit-tests can be as used as a starting point.
|
232
236
|
|
233
237
|
### Redis Encryption
|
@@ -7,7 +7,6 @@ from contextlib import contextmanager
|
|
7
7
|
|
8
8
|
SENTINEL = object()
|
9
9
|
|
10
|
-
|
11
10
|
transform_type = Dict[str, Callable[[str], Any]]
|
12
11
|
pre_transform_type = Dict[str, Callable[[Any], str]]
|
13
12
|
|
@@ -132,7 +131,7 @@ class RedisDict:
|
|
132
131
|
Args:
|
133
132
|
namespace (str, optional): A prefix for keys stored in Redis.
|
134
133
|
expire (int, timedelta, optional): Expiration time for keys in seconds.
|
135
|
-
preserve_expiration (bool, optional):
|
134
|
+
preserve_expiration (bool, optional): Preserve the expiration count when the key is updated.
|
136
135
|
**redis_kwargs: Additional keyword arguments passed to StrictRedis.
|
137
136
|
"""
|
138
137
|
self.temp_redis: Optional[StrictRedis[Any]] = None
|
@@ -234,7 +233,7 @@ class RedisDict:
|
|
234
233
|
"""
|
235
234
|
self.transform[k] = v
|
236
235
|
|
237
|
-
def
|
236
|
+
def __eq__(self, other: Any) -> bool:
|
238
237
|
"""
|
239
238
|
Compare the current RedisDict with another object.
|
240
239
|
|
@@ -242,22 +241,26 @@ class RedisDict:
|
|
242
241
|
other (Any): The object to compare with.
|
243
242
|
|
244
243
|
Returns:
|
245
|
-
|
246
|
-
Note:
|
247
|
-
TODO add the following methods
|
248
|
-
__lt__(self, other)
|
249
|
-
__le__(self, other)
|
250
|
-
__eq__(self, other)
|
251
|
-
__ne__(self, other)
|
252
|
-
__gt__(self, other)
|
253
|
-
__ge__(self, other)
|
244
|
+
bool: True if equal, False otherwise
|
254
245
|
"""
|
255
246
|
if len(self) != len(other):
|
256
|
-
return
|
247
|
+
return False
|
257
248
|
for key, value in self.iteritems():
|
258
249
|
if value != other.get(key, SENTINEL):
|
259
|
-
return
|
260
|
-
return
|
250
|
+
return False
|
251
|
+
return True
|
252
|
+
|
253
|
+
def __ne__(self, other: Any) -> bool:
|
254
|
+
"""
|
255
|
+
Compare the current RedisDict with another object.
|
256
|
+
|
257
|
+
Args:
|
258
|
+
other (Any): The object to compare with.
|
259
|
+
|
260
|
+
Returns:
|
261
|
+
bool: False if equal, True otherwise
|
262
|
+
"""
|
263
|
+
return not self.__eq__(other)
|
261
264
|
|
262
265
|
def __getitem__(self, item: str) -> Any:
|
263
266
|
"""
|
@@ -400,14 +403,14 @@ class RedisDict:
|
|
400
403
|
|
401
404
|
def iterkeys(self) -> Iterator[str]:
|
402
405
|
"""
|
403
|
-
Note: for
|
406
|
+
Note: for python2 str is needed
|
404
407
|
"""
|
405
408
|
to_rm = len(self.namespace) + 1
|
406
409
|
return (str(item[to_rm:]) for item in self._scan_keys())
|
407
410
|
|
408
411
|
def key(self, search_term: str = '') -> Optional[str]:
|
409
412
|
"""
|
410
|
-
Note: for
|
413
|
+
Note: for python2 str is needed
|
411
414
|
"""
|
412
415
|
to_rm = len(self.namespace) + 1
|
413
416
|
cursor, data = self.get_redis.scan(match='{}:{}{}'.format(self.namespace, search_term, '*'), count=1)
|
@@ -427,7 +430,7 @@ class RedisDict:
|
|
427
430
|
|
428
431
|
def iteritems(self) -> Iterator[Tuple[str, Any]]:
|
429
432
|
"""
|
430
|
-
Note: for
|
433
|
+
Note: for python2 str is needed
|
431
434
|
"""
|
432
435
|
to_rm = len(self.namespace) + 1
|
433
436
|
for item in self._scan_keys():
|
@@ -543,7 +546,7 @@ class RedisDict:
|
|
543
546
|
|
544
547
|
Args:
|
545
548
|
key (str): The key to retrieve the value.
|
546
|
-
|
549
|
+
default_value (Optional[Any], optional): The value to set if the key is not found.
|
547
550
|
|
548
551
|
Returns:
|
549
552
|
Any: The value associated with the key or the default value.
|
@@ -572,7 +575,7 @@ class RedisDict:
|
|
572
575
|
Update the RedisDict with key-value pairs from the given mapping, analogous to a dictionary's update method.
|
573
576
|
|
574
577
|
Args:
|
575
|
-
|
578
|
+
dic (Mapping[str, Any]): A mapping containing key-value pairs to update the RedisDict.
|
576
579
|
"""
|
577
580
|
with self.pipeline():
|
578
581
|
for key, value in dic.items():
|
@@ -639,8 +642,10 @@ class RedisDict:
|
|
639
642
|
"""
|
640
643
|
return self.__delitem__(':'.join(iterable))
|
641
644
|
|
645
|
+
# def expire_at(self, sec_epoch: int | timedelta) -> Iterator[None]:
|
646
|
+
# compatibility with Python 3.9 typing
|
642
647
|
@contextmanager
|
643
|
-
def expire_at(self, sec_epoch: int
|
648
|
+
def expire_at(self, sec_epoch: Union[int, timedelta]) -> Iterator[None]:
|
644
649
|
"""
|
645
650
|
Context manager to set the expiration time for keys in the RedisDict.
|
646
651
|
|
@@ -741,13 +746,13 @@ class RedisDict:
|
|
741
746
|
def get_ttl(self, key: str) -> Optional[int]:
|
742
747
|
"""
|
743
748
|
Get the Time To Live (TTL) in seconds for a given key. If the key does not exist or does not have an
|
744
|
-
associated expire
|
749
|
+
associated `expire`, return None.
|
745
750
|
|
746
751
|
Args:
|
747
752
|
key (str): The key for which to get the TTL.
|
748
753
|
|
749
754
|
Returns:
|
750
|
-
Optional[int]: The TTL in seconds if the key exists and has an
|
755
|
+
Optional[int]: The TTL in seconds if the key exists and has an expiry set; otherwise, None.
|
751
756
|
"""
|
752
757
|
val = self.redis.ttl(self._format_key(key))
|
753
758
|
if val < 0:
|
@@ -17,7 +17,7 @@ setup(
|
|
17
17
|
long_description=long_description,
|
18
18
|
long_description_content_type='text/markdown',
|
19
19
|
|
20
|
-
version='2.
|
20
|
+
version='2.5.1',
|
21
21
|
py_modules=['redis_dict'],
|
22
22
|
install_requires=['redis',],
|
23
23
|
license='MIT',
|
@@ -41,6 +41,6 @@ setup(
|
|
41
41
|
'Programming Language :: Python :: 3.9',
|
42
42
|
'Programming Language :: Python :: 3.10',
|
43
43
|
'Programming Language :: Python :: 3.11',
|
44
|
+
'Programming Language :: Python :: 3.12',
|
44
45
|
],
|
45
46
|
)
|
46
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|