跳转到主要内容

基于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 (6.7 kB 查看哈希值)

上传时间:

构建分布

persistentdict-1.0.1-py3-none-any.whl (4.9 kB 查看哈希值)

上传时间: Python 3

由以下支持