redis-dict 3.2.0__py3-none-any.whl → 3.2.2__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: redis-dict
3
- Version: 3.2.0
3
+ Version: 3.2.2
4
4
  Summary: Dictionary with Redis as storage backend
5
5
  Author-email: Melvin Bijman <bijman.m.m@gmail.com>
6
6
  License: MIT
@@ -42,7 +42,7 @@ Requires-Dist: types-redis>=4.6.0; extra == "dev"
42
42
  Requires-Dist: typing_extensions>=4.5.0; extra == "dev"
43
43
  Requires-Dist: attrs==22.2.0; extra == "dev"
44
44
  Requires-Dist: cffi==1.15.1; extra == "dev"
45
- Requires-Dist: cryptography==43.0.1; extra == "dev"
45
+ Requires-Dist: cryptography==44.0.1; extra == "dev"
46
46
  Requires-Dist: exceptiongroup==1.1.1; extra == "dev"
47
47
  Requires-Dist: future==0.18.3; extra == "dev"
48
48
  Requires-Dist: pycparser==2.21; extra == "dev"
@@ -71,12 +71,14 @@ Requires-Dist: build; extra == "build"
71
71
  Requires-Dist: twine; extra == "build"
72
72
 
73
73
  # Redis-dict
74
+
74
75
  [![PyPI](https://img.shields.io/pypi/v/redis-dict.svg)](https://pypi.org/project/redis-dict/)
75
76
  [![CI](https://github.com/Attumm/redis-dict/actions/workflows/ci.yml/badge.svg)](https://github.com/Attumm/redis-dict/actions/workflows/ci.yml)
76
77
  [![codecov](https://codecov.io/gh/Attumm/redis-dict/graph/badge.svg?token=Lqs7McQGEs)](https://codecov.io/gh/Attumm/redis-dict)
78
+ [![Documentation](https://img.shields.io/badge/docs-sphinx-blue.svg)](https://attumm.github.io/redis-dict/)
77
79
  [![Downloads](https://static.pepy.tech/badge/redis-dict/month)](https://pepy.tech/project/redis-dict)
78
80
 
79
- RedisDict is a Python library that offers a convenient and familiar interface for interacting with Redis, treating it as if it were a Python dictionary. Its goal is to help developers write clean, Pythonic code while using Redis as a storage solution for seamless distributed computing. This simple yet powerful library utilizes Redis as a key-value store and supports various data types, including strings, integers, floats, booleans, lists, and dictionaries. Additionally, developers can extend RedisDict to work with custom objects.
81
+ RedisDict is a Python library that offers a convenient and familiar interface for interacting with Redis, treating it as if it were a Python dictionary. Its goal is to help developers write clean, Pythonic code while using Redis as a storage solution for seamless distributed computing. Redis-Dict utilizes Redis as a key-value store and supports various data types, including strings, integers, floats, booleans, lists, and dictionaries. Additionally, developers can extend RedisDict to work with custom objects.
80
82
 
81
83
  The library includes utility functions for more complex use cases such as caching, batching, and more. By leveraging Redis for efficient key-value storage, RedisDict enables high-performance data management, maintaining efficiency even with large datasets and Redis instances.
82
84
 
@@ -93,7 +95,6 @@ The library includes utility functions for more complex use cases such as cachin
93
95
  * Encryption: allows for storing data encrypted, while retaining the simple dictionary interface.
94
96
 
95
97
  ## Example
96
- Redis is an exceptionally fast database when used appropriately. RedisDict leverages Redis for efficient key-value storage, enabling high-performance data management.
97
98
 
98
99
  ```bash
99
100
  pip install redis-dict
@@ -110,6 +111,8 @@ True
110
111
  >>> dic["baz"] = "hello world"
111
112
  >>> dic
112
113
  {'foo': 42, 'baz': 'hello world'}
114
+ >>> from datetime import datetime
115
+ >>> dic["datetime"] = datetime.now()
113
116
  ```
114
117
  In Redis our example looks like this.
115
118
  ```
@@ -120,11 +123,13 @@ In Redis our example looks like this.
120
123
  "int:42"
121
124
  127.0.0.1:6379> GET "main:baz"
122
125
  "str:hello world"
126
+ 127.0.0.1:6379> GET "main:datetime"
127
+ "datetime:2025-02-20T19:37:54.214274"
123
128
  ```
124
129
 
125
130
  ## Types
126
131
 
127
- ### standard types
132
+ ### Standard types
128
133
  RedisDict supports a range of Python data types, from basic types to nested structures.
129
134
  Basic types are handled natively, while complex data types like lists and dictionaries, RedisDict uses JSON serialization, specifically avoiding [pickle](https://docs.python.org/3/library/pickle.html) due to its security vulnerabilities within distributed computing contexts.
130
135
  Although the library supports nested structures, the recommended best practice is to use RedisDict as a shallow dictionary.
@@ -132,6 +137,8 @@ This approach optimizes Redis database performance and efficiency by ensuring th
132
137
  Following types are supported:
133
138
  `str, int, float, bool, NoneType, list, dict, tuple, set, datetime, date, time, timedelta, Decimal, complex, bytes, UUID, OrderedDict, defaultdict, frozenset`
134
139
  ```python
140
+ from redis_dict import RedisDict
141
+
135
142
  from uuid import UUID
136
143
  from decimal import Decimal
137
144
  from collections import OrderedDict, defaultdict
@@ -239,7 +246,7 @@ dic = RedisDict(namespace="example")
239
246
  print(dic["foo"]) # outputs "bar"
240
247
  ```
241
248
 
242
- ## More Examples
249
+ ## Additional Examples
243
250
 
244
251
  ### Caching made simple
245
252
  ```python
@@ -326,6 +333,19 @@ print(key, value) # Output: 'c' 3 (example)
326
333
  # Using setdefault() method
327
334
  dic.setdefault("d", 4)
328
335
  print(dic["d"]) # Output: 4
336
+
337
+ from datetime import datetime, timedelta
338
+
339
+ # Redis dict support datetime
340
+ dic["now"] = datetime.now()
341
+ print(dic["now"]) # 2025-02-20 19:25:38.835816
342
+
343
+ # SRedis dict support timedelta and more types
344
+ dic["time"] = timedelta(days=1)
345
+ print(dic["time"]) # 1 day, 0:00:00
346
+
347
+ print(dic)
348
+ {'now': datetime.datetime(2025, 2, 20, 19, 25, 38, 835816), 'time': datetime.timedelta(days=1), 'b': 2, 'd': 4}
329
349
  ```
330
350
 
331
351
  ### Additional Examples
@@ -333,7 +353,6 @@ For more advanced examples of RedisDict, please refer to the unit-test files in
333
353
  The unit-tests can be as used as a starting point.
334
354
 
335
355
  ### Nested types
336
- Nested Types
337
356
  RedisDict supports nested structures with mixed types through JSON serialization. The feature works by utilizing JSON encoding and decoding under the hood. While this represents an upgrade in functionality, the feature is not fully implemented and should be used with caution. For optimal performance, using shallow dictionaries is recommended.
338
357
  ```python
339
358
  from datetime import datetime, timedelta
@@ -355,12 +374,10 @@ encoded = json.dumps(data, cls=RedisDictJSONEncoder)
355
374
  result = json.loads(encoded, cls=RedisDictJSONDecoder)
356
375
  ```
357
376
 
358
-
359
377
  ### Extending RedisDict with Custom Types
360
378
 
361
379
  RedisDict supports custom type serialization. Here's how to add a new type:
362
380
 
363
-
364
381
  ```python
365
382
  import json
366
383
 
@@ -3,8 +3,8 @@ redis_dict/core.py,sha256=E9mry6BqFnMjxuPtYBfQfuUPzWNzF65_dILMa-VgI4A,36994
3
3
  redis_dict/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  redis_dict/python_dict.py,sha256=FLsvxOfgkzsBJdRMkMrZw3w1usoGs-0FEL-j_ckfKts,12829
5
5
  redis_dict/type_management.py,sha256=ruyqswKqfte_G-ClTlV6ZuTmrTVkSsHFCy9LEdgblac,7700
6
- redis_dict-3.2.0.dist-info/LICENSE,sha256=-QiLwYznh_vNUSz337k0faP9Jl0dgtCIHVZ39Uyl6cA,1070
7
- redis_dict-3.2.0.dist-info/METADATA,sha256=k7dAwv3MM-W1fYvOprUzknBXHkZDRFJd_5uI4UMWpw4,17531
8
- redis_dict-3.2.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
9
- redis_dict-3.2.0.dist-info/top_level.txt,sha256=Wyp5Xvq_imoxvu-c-Le1rbTZ3pYM5BF440H9YAcgBZ8,11
10
- redis_dict-3.2.0.dist-info/RECORD,,
6
+ redis_dict-3.2.2.dist-info/LICENSE,sha256=-QiLwYznh_vNUSz337k0faP9Jl0dgtCIHVZ39Uyl6cA,1070
7
+ redis_dict-3.2.2.dist-info/METADATA,sha256=67iNEV13g4Wjk6sSgoYYZLf30ct4QDcLVj1dZp25xto,18011
8
+ redis_dict-3.2.2.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
9
+ redis_dict-3.2.2.dist-info/top_level.txt,sha256=Wyp5Xvq_imoxvu-c-Le1rbTZ3pYM5BF440H9YAcgBZ8,11
10
+ redis_dict-3.2.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5