redis支持的一组基本python集合。

redis-collections的Python项目详细描述


https://travis-ci.org/honzajavorek/redis-collections.svg?branch=masterhttps://coveralls.io/repos/github/honzajavorek/redis-collections/badge.svg?branch=master

redis collections是一个提供高级 接口到Redis,优秀的键值存储。

快速启动

使用pip install redis-collections安装库。 从顶层redis_collections包导入集合。

标准系列

标准集合(例如DictListSet)的行为与 python对应项:

>>>fromredis_collectionsimportDict,List,Set>>>D=Dict()>>>D['answer']=42>>>D['answer']42
CollectionRedis typeDescription
^{tt3}$HashEmulates Python’s ^{tt7}$
^{tt4}$ListEmulates Python’s ^{tt9}$
^{tt5}$SetEmulates Python’s ^{tt11}$
^{tt12}$HashEmulates Python’s ^{tt13}$
^{tt14}$HashEmulates Python’s ^{tt15}$
^{tt16}$ListEmulates Python’s ^{tt17}$

可同步的集合

此包中的可同步集合提供 内容保存在内存中。当它们的sync方法被调用时 内容写入redis:

>>>fromredis_collectionsimportSyncableDict>>>withSyncableDict()asD:...D['a']=1# No write to Redis...D['a']+=1# No read from or write to Redis>>>D['a']# D.sync() is called at the end of the with block2
CollectionPython typeDescription
^{tt19}$^{tt7}$Syncs to a Redis Hash
^{tt21}$^{tt9}$Syncs to a Redis List
^{tt23}$^{tt11}$Syncs to a Redis Set
^{tt25}$^{tt13}$Syncs to a Redis Hash
^{tt27}$^{tt17}$Syncs to a Redis List
^{tt29}$^{tt15}$Syncs to a Redis Hash

其他收藏

LRUDict集合将最近使用的项存储在内存中。 它将旧项目推送到redis:

>>>fromredis_collectionsimportLRUDict>>>D=LRUDict(maxsize=2)>>>D['a']=1>>>D['b']=2>>>D['c']=2# 'a' is pushed to Redis and 'c' is stored locally>>>D['a']# 'b' is pushed to Redis and 'a' is retrieved for local storage1>>>D.sync()# All items are copied to Redis

SortedSetCounter提供对redis的访问 Sorted Set类型:

>>>fromredis_collectionsimportSortedSetCounter>>>ssc=SortedSetCounter([('earth',300),('mercury',100)])>>>ssc.set_score('venus',200)>>>ssc.get_score('venus')200.0>>>ssc.items()[('mercury',100.0),('venus',200.0),('earth',300.0)]

文档

有关详细信息,请参见 redis-collections.readthedocs.io

维护人员

许可证:ISC

版权所有2013-?本扎哈沃雷克mail@honzajavorek>;

这项工作是根据ISC license授权的。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
ssl证书javax。网ssl。SSLHandshakeException:java。安全cert.CertificateException:没有与IP地址匹配的主题替代名称   基于组件的体系结构的java粒度   java在读取文件中的下一行和上一行时,我得到一个空指针异常   java是什么。StrutConfig。xml。strutsdia文件?   java中如何根据枚举字段对一组对象进行排序   java Firebase setPersistenceEnabled。导致大量内存使用   java奇数编译泛型类和列表错误   java类型org没有可用的源代码。石英克隆表达;您是否忘记继承所需的模块?   java如何使用map计算列表中整数列表的和,并获得一个新列表,其中每个条目对应于每个计算出的和?   java二进制搜索不会结束   java跳过Jackson中的错误JSON数据   在服务层中使用依赖项注入时引发java空指针异常。DAO类bean为空   访问者模式如何解释这两个Java程序运行时间的差异?   用Java扩展日历   java调用通用静态方法