Object oriented interface to aioredis.
Project description
Async Redis Objects
Some object orient wrappers around the redis interface provided by aioredis
.
Notes
- Included:
- hash table
- queue (list)
- priority queue (sorted set)
- locks (keys)
- Includes python implementation with matching interface for mocking.
from async_redis_objects.mocks import ObjectClient
- tested on pypy and CPython 3.6 to 3.9
- API documentation on read the docs
Example
import aioredis
import asyncio
from async_redis_objects import ObjectClient
async def main():
# Connect with aioredis as normal
redis = aioredis.Redis(await aioredis.pool.create_pool(address='redis://redis:6379', db=3, minsize=5))
# Make an object client object with your redis object
objects = ObjectClient(redis)
# Access a hash table in redis
table = objects.hash('hash-table-key')
await table.set('name', 'Hello World')
# Access a queue
queue = objects.queue('queue-name')
await queue.push(await table.get('name'))
await queue.push(100000)
# Access a priority queue
pq = objects.priority_queue('other-queue-name')
await pq.push({'name': 'same json serializable object'}, priority=100)
await pq.push(await queue.pop(), priority=101)
print(await pq.pop()) # Print Hello World
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
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
Built Distribution
Close
Hashes for async_redis_objects-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7aa2ea1522617196809b370e080264d79119ce1b6493188ee88d95fe6eb89f0 |
|
MD5 | 74c9f1a374d8d032d0d421d4725f5108 |
|
BLAKE2b-256 | e26a42a093295db1b636ccf354929dfc1d5ef47f44ad61ca6d67e3110dcf7121 |
Close
Hashes for async_redis_objects-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8101133f95465971fc65c2084dd29ce4c126cf441d961d6155d5c76c5834f43 |
|
MD5 | 63d935f1fbd07034889d33c045bed326 |
|
BLAKE2b-256 | 2f701b2a01cb8b81e0b804c49f5bfb8e96a262da38f82253e10435f623c7a7ed |