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第三方库


热门话题
java JAXB封送字符串,具有xml值,且不转义该值   java ModelMapper转换器不工作   java像HH000412或HCANN000001这样的前缀是什么意思?   验证日期输入修复java。lang.numberformatexception错误   当表具有外键时,java Telosys代码生成失败   如何使所有派生类一起只能实例化一个实例的单例抽象基类?(爪哇)   java如何在非静态服务类中使用广播接收器   java nutch爬虫相对URL问题   使用Jboss DMR下载/保存java附件   Rest模板:无法提取响应:当我们得到xml响应时,没有找到适合响应类型的HttpMessageConverter,没有绑定到JAVA对象   java如何编写可扩展窗格/面板/卡的代码   java是在ITreeViewerListener的treeExpanded()之前调用ContentProvider的getChildren()吗?   java将JComponent添加到小程序窗格   java混淆:使用简单逻辑的Flames程序