Lightweight queue interfaces with Redis super powers for distributed and non-distributed systems
Project description
Lightweight queue interfaces with Redis super powers
Description
PimPamQueues provides easy and lightweight Python interfaces to interact with queues on a distributed system.
Requirements
Python 2.7 or 3.4, python.org
A runing Redis server, redis.io
Redis Python library, redis-py.readthedocs.org
Features
Supports at least Python 2.7 and 3.4.
Provides super-simple queue interfaces for creating different types of queues.
Designed to be used on distributed systems - also works on non-distributed systems ;).
Queue Interfaces
SimpleQueue, just a regular queue.
BucketQueue, unordered queue of unique elements with a extreamly fast element existance search method.
SmartQueue, queue which stores queued elements aside the queue for not queueing the same incoming elements again.
Usage
SimpleQueue
>>> from pimpamqueues.simplequeue import SimpleQueue
>>> queue = SimpleQueue(id_args=['simplequeue'])
>>> queue.num()
0
>>> queue.push('egg')
1
>>> queue.push_some(['bacon', 'spam'])
3
>>> queue.num()
3
>>> queue.pop()
b'egg'
>>> queue.is_empty()
False
>>> queue.push('spam', to_first=True)
3
>>> queue.elements()
[b'spam', b'bacon', b'spam']
>>> queue.pop()
b'spam'
>>> queue.elements()
[b'bacon', b'spam']
...
BucketQueue
>>> from pimpamqueues.bucketqueue import BucketQueue
>>> queue = BucketQueue(id_args=['bucketqueue'])
>>> queue.num()
0
>>> queue.push('egg')
'egg'
>>> queue.push_some(['bacon', 'spam'])
[b'bacon', b'spam']
>>> queue.num()
3
>>> queue.pop()
b'spam'
>>> queue.is_empty()
False
>>> queue.push('spam')
'spam'
>>> queue.elements()
{b'bacon', b'egg', b'spam'}
>>> queue.pop()
b'spam'
>>> queue.elements()
{b'bacon', b'egg'}
...
SmartQueue
>>> from pimpamqueues.smartqueue import SmartQueue
>>> queue = SmartQueue(id_args=['smartqueue'])
>>> queue.num()
0
>>> queue.push('egg')
'egg'
>>> queue.push_some(['bacon', 'spam'])
[b'bacon', b'spam']
>>> queue.num()
3
>>> queue.pop()
b'egg'
>>> queue.is_empty()
False
>>> queue.push('spam', to_first=True)
''
>>> queue.elements()
[b'bacon', b'spam']
>>> queue.pop()
b'bacon'
>>> queue.elements()
[b'spam']
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pimpamqueues-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26c39afd01195cdd5b9a7d4b8d69e7340cfe162fe0f2e94d236ed4029a24edff |
|
MD5 | 8d1177d9fdccf016eaf1bed1927fd838 |
|
BLAKE2b-256 | d9fe4a9685d3857b55b83ea4d0150e5f4fc8cb5a17cfb1b0813385ac1f516f09 |