Python async client for Redis key-value store
Project description
An async version of redis-py (which is a Python interface to the Redis key-value store).
Installation
aredis requires a running Redis server.
To install redis-py, simply:
$ sudo pip3 install aredis
or alternatively (you really should be using pip though):
$ sudo easy_install aredis
or from source:
$ sudo python setup.py install
Getting Started
>>> import aredis
>>> import asyncio
>>> r = aredis.StrictRedis(host='localhost', port=6379, db=0)
>>> loop = asyncio.get_event_loop()
>>> async def test():
>>> await r.set('foo', 'bar')
>>> print(await r.get('foo'))
>>> loop.run_until_complete(test())
b'bar'
API Reference
The connection part is rewritten to make client async, and most API is ported from redis-py. So most API and usage are the same as redis-py. If you use redis-py in your code, just use async/await syntax with your code.
iter functions are not supported now
doc in detail is coming soon
Advantage
aredis can be used howerver you install hiredis or not.
aredis’ API are mostly ported from redis-py, which is easy to use indeed and make it easy to port your code with asyncio
according to my test, aredis is efficient enough (please run benchmarks/comparation.py to see which async redis client is suitable for you)
aredis can be run both with asyncio and uvloop, the latter can double the speed of your async code.
Disadvantage & TODO
the package only support Python 3.5 and above
the encode part is not supported very well now (will try to fix it in next version)
iter functions are not supported now (will be added in Python 3.6)
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.