格林德克雷迪斯包
greendeck-redis的Python项目详细描述
绿色甲板Redis
仅为内部Greendeck
使用而创建。可用于非商业目的。
一个简单的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.
redis
客户端连接redis set
redis
查找两个redis集的差异redis queue
如何构建pip包
- 在这里开户https://pypi.org/
在父目录中
python setup.py sdist bdist_wheel
twine upload dist/*
参考资料