基于Redis数据库的另一个字典
项目描述
persistentdict
基于Redis数据库的另一个[1]字典。
我们使用Redis的'hash'类型[2],将整个字典存储在一个hash中。
用法
from persistentdict.dict_in_redis import PersistentDict
db = PersistentDict(hash_name="my-persistent-dict")
# add key to the db with a value
db['key'] = value
# show whole dictionary
print(db)
# iterate over keys & values in db
for key, value in db.items():
do_something(key)
# do sth with key if it is in db
if key in db:
do_something(key)
# delete key from db
del db['key']
安装
pip3 install persistentdict
[1] 替代方案: persistent-dict, durabledict
[2] https://redis.ac.cn/topics/data-types-intro#hashes 是基本的Python字典,但值只能是字符串,所以我们使用json序列化
项目详情
关闭
persistentdict-1.0.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4077de2489a28a7757cb8afa32341811bbd7947249ea2cd0b0cf6c0bafc705ed |
|
MD5 | 1faffc2c972fb22ec7de082a24a32e1c |
|
BLAKE2b-256 | 4f190a4e80f0c00cb5b83111939daa3b25e4ab7068ecb7f761ec5020b8d0bac9 |
关闭
persistentdict-1.0.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e768ddd195ac9b9fb8fb0b6a3ebca477e13a8168d6a6cb03f5d381bc7a7c681c |
|
MD5 | 9bbaa4288a3fdc6a1048d585afa6ec4c |
|
BLAKE2b-256 | 2ab6c3c6f9927482652d4896e6fe71499f49458bd75f180d7f6e31db5b6420c8 |