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.

Source Distribution

greendeck-redis-1.0.5.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file greendeck-redis-1.0.5.tar.gz.

File metadata

  • Download URL: greendeck-redis-1.0.5.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8

File hashes

Hashes for greendeck-redis-1.0.5.tar.gz
Algorithm Hash digest
SHA256 4df562d2188b66f5f4d05157359d94d26e2199c19e54c8a07abac54faf5784e1
MD5 af078bd23a6c9f1c139fa0822e4681d9
BLAKE2b-256 379158205788c4db85c4c5add81e76c92442189dcdbfce4b19b5f8c5d79b87d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page