Skip to main content

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.

Source Distribution

moonqueue-0.3.1.tar.gz (4.0 kB view hashes)

Uploaded source

Built Distribution

moonqueue-0.3.1-py3-none-any.whl (17.2 kB view hashes)

Uploaded 3 7

Supported by

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