Skip to main content

Object orient interface to aioredis.

Project description

Actions Status codecov

Async Redis Objects

Some object orient wrappers around the redis interface provided by aioredis.

Notes

  • Included:
    • hash table
    • queue (list)
    • priority queue (sorted set)
  • Includes python implementation with matching interface for mocking.
    from async_redis_objects.mocks import ObjectClient

Example

import aioredis
import asyncio
from async_redis_objects.mocks import ObjectClient


async def main():
    # Connect with aioredis as normal
    redis = aioredis.Redis(await aioredis.pool.create_pool(address='redis://localhost: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.

Files for async-redis-objects, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size async_redis_objects-0.0.3-py3-none-any.whl (6.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size async_redis_objects-0.0.3.tar.gz (4.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page