Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Queue Implementation with Redis

Project description

https://img.shields.io/badge/License-GPL%20v3-blue.svg https://badge.fury.io/py/moonqueue.svg https://img.shields.io/travis/Gatsby-Lee/moonqueue.svg

moonqueue

MoonQueue is another Queue Library using Redis as storage.

How to Install

pip install moonqueue

How To Use

RedisQueueList - One Queue

>>> from moonqueue import RedisQueueList
>>> r = RedisQueueList('list:myqueue')

# push one message
>>> r.push(['apple'])
(('list:myqueue', 1),)
>>> r.pop()
('list:myqueue', b'apple')

# push multiple messages
>>> r.push(['apple', 'banana'])
(('list:myqueue', 2),)
>>> r.pop()
('list:myqueue', b'apple')
>>> r.pop()
('list:myqueue', b'banana')
>>> r.pop()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/web/moonqueue/moonqueue/redis_queue_list.py", line 52, in pop
    raise EmptyQueueException(excep_msg)
moonqueue.excep.EmptyQueueException: list:myqueue is empty

RedisQueueList - Two Queues

>>> from moonqueue import RedisQueueList
>>> r = RedisQueueList(['list:myqueue1', 'list:myqueue2'])
>>> r.get_queues()
['list:myqueue1', 'list:myqueue2']

# push one message - it will be pused to all queues
>>> r.push(['apple'])
(('list:myqueue1', 1), ('list:myqueue2', 1))

# pop from queues
>>> r.pop()
('list:myqueue1', b'apple')
>>> r.pop()
('list:myqueue2', b'apple')
>>> r.pop()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/web/moonqueue/moonqueue/redis_queue_list.py", line 52, in pop
    raise EmptyQueueException(excep_msg)
moonqueue.excep.EmptyQueueException: ['list:myqueue1', 'list:myqueue2'] is empty

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 moonqueue, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size moonqueue-0.3.1-py3-none-any.whl (17.2 kB) File type Wheel Python version 3.7 Upload date Hashes View
Filename, size moonqueue-0.3.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page