格林德克雷迪斯包

greendeck-redis的Python项目详细描述


绿色甲板Redis

仅为内部Greendeck使用而创建。可用于非商业目的。

Greendeckredis

一个简单的redis库,用于创建redis集和redis队列并对其执行基本操作。

从PIP安装

https://pypi.org/project/greendeck-redis/

pip install greendeck-redis

如何使用?

导入库
importgreendeck_redis
或导入{}类
fromgreendeck_redisimportRedisQueuefromgreendeck_redisimportRedisSetfromgreendeck_redisimportRedis# This will be used for operations that require two or more redis keys (Set or Queue)
根据您的要求初始化redis客户端连接
# declare variablesREDIS_HOST=<YOUR_REDIS_HOST>REDIS_PORT=<YOUR_REDIS_PORT>REDIS_PASSWORD=<YOUR_REDIS_PASSWORD># Here default values are REDIS_PORT='', REDIS_HOST='', REDIS_PASSWORD=Noneredis_queue=RedisQueue(REDIS_HOST,REDIS_PORT,queue_name,password=REDIS_PASSWORD)# OR/ANDredis_set=RedisSet(REDIS_HOST,REDIS_PORT,set_name,password=REDIS_PASSWORD)# OR/ANDredis_client=Redis(REDIS_HOST,REDIS_PORT,password=REDIS_PASSWORD)# This will be used for operations that require two or more redis keys (Set or Queue)
使用redis set
redis_set.smembers()# will return all the member strings of the RedisSet ```redis_set``` in a python list.redis_set.scard()# will return the count of members of the RedisSet ```redis_set``` as an integer.redis_set.put(item)# will insert ```item``` string in the RedisSet ```redis_set``` if not already present. RedisSet doesn't allow dupicate values.
使用redis查找两个redis集的差异
redis_client.sdiffstore(target_set_name,operand1_set_name,operand2_set_name)# this creates a new RedisSet with the name ```target_set_name``` and contains the difference of ```operand1_set_name``` and ```operand2_set_name```.
使用redis queue
redis_queue.qsize()# will return the count of members of the RedisQueue ```redis_queue``` as an integer.redis_queue.put(item)# will insert ```item``` string in the RedisQueue ```redis_queue``` even if it is already present. RedisQueue allows duplicate values.redis_queue.empty()# will clear all the member strings of the RedisQueue ```redis_queue``` in a python list.redis_queue.get()# will return the first member string (single) of the RedisQueue ```redis_queue``` as a string.redis_queue.get_multi(n)# will return the first ```n``` member strings (count: n) of the RedisQueue ```redis_queue``` as a python list. if the count of members in the RedisQueue is less than ```n```; it will return all the members as a python list.redis_queue.get_nowait()# will return all members of the RedisQueue ```redis_queue``` as a python list.

如何构建pip包

在父目录中

  • python setup.py sdist bdist_wheel
  • twine upload dist/*

参考资料

谢谢

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

推荐PyPI第三方库


热门话题
hashmap Java如何以列表作为值组织映射   java二进制搜索树如何在“main”中调用我的inoder方法,并在输出中省略null?   java Subclipse如何覆盖更改的文件   java无法识别的VM选项“ExplicitGCInvokesConcurrentAndUnloadsClasses”   java需要从字符串中转义“| |”条件   JavaMVEL迭代列表   如果有对元素字段的引用,java会对元素进行垃圾收集吗?   java如何按索引删除行   java有没有简单的http服务来检查域名的可用性   java Spring@ContextConfiguration无法从不同的项目加载测试上下文   IntelliJ IDEA社区版中的java Webservice客户端   netbeans从java Main调用另一个java文件中的方法   java MySQL左连接和组连接返回重复和中断数据   Java\Hibernate\ManyTone\Ordering   java JPQL中的LIMIT子句是什么?   在Java中,预处理器将单词转换为基本形式   在核心java中创建GUI时的swing问题   java从javabean创建不可变对象   java线程是否可能在wait()循环中饿死?   java有spring用来从xml解析setter数据的助手类吗?