redis-dict 3.2.1__py3-none-any.whl → 3.2.3__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
1
  Metadata-Version: 2.2
2
2
  Name: redis-dict
3
- Version: 3.2.1
3
+ Version: 3.2.3
4
4
  Summary: Dictionary with Redis as storage backend
5
5
  Author-email: Melvin Bijman <bijman.m.m@gmail.com>
6
6
  License: MIT
@@ -71,15 +71,22 @@ 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
 
85
+
86
+ [Usage](#Usage) | [Types](#Types) | [Expiration](#Expiration) | [Batching](#Batching) | [Custom Types](#Custom-Types) | [Security](#Security)
87
+
88
+ ---
89
+
83
90
  ## Features
84
91
 
85
92
  * Dictionary-like interface: Use familiar Python dictionary syntax to interact with Redis.
@@ -92,8 +99,7 @@ The library includes utility functions for more complex use cases such as cachin
92
99
  * Custom data: types: Add custom types encoding/decoding to store your data types.
93
100
  * Encryption: allows for storing data encrypted, while retaining the simple dictionary interface.
94
101
 
95
- ## Example
96
- Redis is an exceptionally fast database when used appropriately. RedisDict leverages Redis for efficient key-value storage, enabling high-performance data management.
102
+ ## Usage
97
103
 
98
104
  ```bash
99
105
  pip install redis-dict
@@ -110,6 +116,8 @@ True
110
116
  >>> dic["baz"] = "hello world"
111
117
  >>> dic
112
118
  {'foo': 42, 'baz': 'hello world'}
119
+ >>> from datetime import datetime
120
+ >>> dic["datetime"] = datetime.now()
113
121
  ```
114
122
  In Redis our example looks like this.
115
123
  ```
@@ -120,11 +128,13 @@ In Redis our example looks like this.
120
128
  "int:42"
121
129
  127.0.0.1:6379> GET "main:baz"
122
130
  "str:hello world"
131
+ 127.0.0.1:6379> GET "main:datetime"
132
+ "datetime:2025-02-20T19:37:54.214274"
123
133
  ```
124
134
 
125
135
  ## Types
126
136
 
127
- ### standard types
137
+ ### Standard types
128
138
  RedisDict supports a range of Python data types, from basic types to nested structures.
129
139
  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
140
  Although the library supports nested structures, the recommended best practice is to use RedisDict as a shallow dictionary.
@@ -132,6 +142,8 @@ This approach optimizes Redis database performance and efficiency by ensuring th
132
142
  Following types are supported:
133
143
  `str, int, float, bool, NoneType, list, dict, tuple, set, datetime, date, time, timedelta, Decimal, complex, bytes, UUID, OrderedDict, defaultdict, frozenset`
134
144
  ```python
145
+ from redis_dict import RedisDict
146
+
135
147
  from uuid import UUID
136
148
  from decimal import Decimal
137
149
  from collections import OrderedDict, defaultdict
@@ -239,7 +251,7 @@ dic = RedisDict(namespace="example")
239
251
  print(dic["foo"]) # outputs "bar"
240
252
  ```
241
253
 
242
- ## More Examples
254
+ ## Additional Examples
243
255
 
244
256
  ### Caching made simple
245
257
  ```python
@@ -326,14 +338,26 @@ print(key, value) # Output: 'c' 3 (example)
326
338
  # Using setdefault() method
327
339
  dic.setdefault("d", 4)
328
340
  print(dic["d"]) # Output: 4
341
+
342
+ from datetime import datetime, timedelta
343
+
344
+ # Redis dict support datetime
345
+ dic["now"] = datetime.now()
346
+ print(dic["now"]) # 2025-02-20 19:25:38.835816
347
+
348
+ # SRedis dict support timedelta and more types
349
+ dic["time"] = timedelta(days=1)
350
+ print(dic["time"]) # 1 day, 0:00:00
351
+
352
+ print(dic)
353
+ {'now': datetime.datetime(2025, 2, 20, 19, 25, 38, 835816), 'time': datetime.timedelta(days=1), 'b': 2, 'd': 4}
329
354
  ```
330
355
 
331
356
  ### Additional Examples
332
- 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).
357
+ 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/tests_load.py#L1).
333
358
  The unit-tests can be as used as a starting point.
334
359
 
335
360
  ### Nested types
336
- Nested Types
337
361
  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
362
  ```python
339
363
  from datetime import datetime, timedelta
@@ -355,12 +379,11 @@ encoded = json.dumps(data, cls=RedisDictJSONEncoder)
355
379
  result = json.loads(encoded, cls=RedisDictJSONDecoder)
356
380
  ```
357
381
 
358
-
382
+ ## Custom Types
359
383
  ### Extending RedisDict with Custom Types
360
384
 
361
385
  RedisDict supports custom type serialization. Here's how to add a new type:
362
386
 
363
-
364
387
  ```python
365
388
  import json
366
389
 
@@ -406,14 +429,22 @@ dic["3"] = "three"
406
429
  assert list(dic.keys()) == ["1", "2", "3"]
407
430
  ```
408
431
 
409
- For more information on [extending types](https://github.com/Attumm/redis-dict/blob/main/tests/unit/extend_types_tests.py).
410
- ### Redis Encryption
432
+ For more information on [extending types](https://github.com/Attumm/redis-dict/blob/main/tests/unit/tests_extend_types.py).
433
+
434
+ ## Security
435
+
436
+ Security is an important aspect of production projects. Redis-dict was developed within a strict compliance environment.
437
+ Best practice in Redis is to use passwords and network encryption through TLS. However, Redis-dict offers an additional feature by using extended types.
438
+ It is possible to store the values of keys encrypted. The values are encrypted with AES GCM, which is currently considered best practice for security.
439
+
440
+ ### Storage Encryption
441
+ For storing data values encrypted can be achieved using encrypted values, more documentation on that later.
442
+ For now code example within this test file. [encrypted test](https://github.com/Attumm/redis-dict/blob/main/tests/unit/tests_encrypt.py).
443
+
444
+ ### Encryption Network
411
445
  Setup guide for configuring and utilizing encrypted Redis TLS for redis-dict.
412
446
  [Setup guide](https://github.com/Attumm/redis-dict/blob/main/docs/tutorials/encrypted_redis.MD)
413
447
 
414
- ### Redis Storage Encryption
415
- For storing encrypted data values, it's possible to use extended types. Take a look at this [encrypted test](https://github.com/Attumm/redis-dict/blob/main/tests/unit/encrypt_tests.py).
416
-
417
448
  ### Tests
418
449
  The RedisDict library includes a comprehensive suite of tests that ensure its correctness and resilience. The test suite covers various data types, edge cases, and error handling scenarios. It also employs the Hypothesis library for property-based testing, which provides fuzz testing to evaluate the implementation
419
450
 
@@ -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.1.dist-info/LICENSE,sha256=-QiLwYznh_vNUSz337k0faP9Jl0dgtCIHVZ39Uyl6cA,1070
7
- redis_dict-3.2.1.dist-info/METADATA,sha256=FYcMGBLGEdqO_98TSrk9r8wgKHLY3q64ngeRf6eTj6A,17531
8
- redis_dict-3.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
9
- redis_dict-3.2.1.dist-info/top_level.txt,sha256=Wyp5Xvq_imoxvu-c-Le1rbTZ3pYM5BF440H9YAcgBZ8,11
10
- redis_dict-3.2.1.dist-info/RECORD,,
6
+ redis_dict-3.2.3.dist-info/LICENSE,sha256=-QiLwYznh_vNUSz337k0faP9Jl0dgtCIHVZ39Uyl6cA,1070
7
+ redis_dict-3.2.3.dist-info/METADATA,sha256=v9NrVJ0-d27ZUx0LwI_cUtdibEWjX7mw9XzQubSjGHs,18672
8
+ redis_dict-3.2.3.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
9
+ redis_dict-3.2.3.dist-info/top_level.txt,sha256=Wyp5Xvq_imoxvu-c-Le1rbTZ3pYM5BF440H9YAcgBZ8,11
10
+ redis_dict-3.2.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5