A Redis-backed persistent Python dictionary
Project description
redis-json-dict
Usage
>>> import redis
... redis_client = redis.Redis("localhost", 6379)
... d = RedisJSONDict(redis_client, prefix="my_dict")
... d
{}
All user modifications, including mutation of nested lists or dicts, are immediately synchronized to the Redis server.
Design Requirements
- The dictionary implements Python's
collections.abc.MutableMapping
interface. - All values stored in Redis are JSON-encoded, readily inspected with developer eyeballs and possible to operate on from clients in languages other than Python.
- Keys may be prefixed to reduce the likelihood of collisions when one Redis is shared by multiple applications.
- No data is cached locally, so it is impossible to obtain a stale result.
However, the dictionary may be composed with other libraries, such as
cachetools
, to implement TTL caching for example. - Top-level items like
d['sample']
may be accessed without synchronizing the entire dictionary. Nested objects liked['sample']['color']
are supported (but may be less efficient). - Mutating nested items, with operations like
d['sample']['color'] = 'red'
ord['sample']['positions'].append(3)
triggers synchronization.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
redis_json_dict-0.2.0.tar.gz
(12.8 kB
view hashes)
Built Distribution
Close
Hashes for redis_json_dict-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 646c657e247c69d79d654c8f5e358342f64f5c5b9794384f844d2f5b4b2a5606 |
|
MD5 | 760203fe065cbb8a816ada2bf5840de8 |
|
BLAKE2b-256 | efb6be7eafca356e9fe7842a064f8a7e8aa63bf80c922ab11f4e72dbdad009ab |