Code Monkey home page Code Monkey logo

async-redis-objects's Introduction

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
  • tested on pypy and CPython 3.6 to 3.8
  • 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())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.