Skip to main content

Greendeck Redis Package

Project description

greendeck-redis

Created for internal Greendeck use only. Can be used for non-commercial purposes.

Greendeck redis

A simple Redis library to create Redis sets and Redis queues and perform basic operations on them.

Install from pip

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

pip install greendeck-redis

How to use ?

import the library
import greendeck_redis
or, import redis classes
from greendeck_redis import RedisQueue
from greendeck_redis import RedisSet
from greendeck_redis import Redis # This will be used for operations that require two or more redis keys (Set or Queue)
initialize redis client connection as per your requirements
# declare variables
REDIS_HOST = <YOUR_REDIS_HOST>
REDIS_PORT = <YOUR_REDIS_PORT>
REDIS_PASSWORD = <YOUR_REDIS_PASSWORD>
# Here default values are REDIS_PORT='', REDIS_HOST='', REDIS_PASSWORD=None

redis_queue = RedisQueue(REDIS_HOST, REDIS_PORT, queue_name, password=REDIS_PASSWORD)
# OR/AND
redis_set = RedisSet(REDIS_HOST, REDIS_PORT, set_name, password=REDIS_PASSWORD)
# OR/AND
redis_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)
using 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.
using redis for finding difference of two redis sets
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```.
using 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.

How to build your pip package

In the parent directory

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

references

Thank You

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for greendeck-redis, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size greendeck_redis-1.0.1-py3-none-any.whl (5.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size greendeck-redis-1.0.1.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page