Yet another [1] dictionary backed by Redis DB.
We use Redis` 'hash' type [2] and store whole dictionary in one hash.
Usage:
frompersistentdict.dict_in_redisimportPersistentDictdb=PersistentDict(hash_name="my-persistent-dict")
# add key to the db with a valuedb['key'] =value# show whole dictionaryprint(db)
# iterate over keys & values in dbforkey, valueindb.items():
do_something(key)
# do sth with key if it is in dbifkeyindb:
do_something(key)
# delete key from dbdeldb['key']Installation:
pip3 install persistentdict[1] Alternatives: persistent-dict, durabledict
[2] https://redis.io/topics/data-types-intro#hashes is basically Python's dict, but values can be strings only, so we use json serialization