Python async client for Redis key-value store
Project description
yaaredis (Yet Another Async Redis (client)) is a fork of aredis, which itself was ported from redis-py. yaaredis provides an efficient and user-friendly async redis client with support for Redis Server, Cluster, and Sentinels.
To get more information please read the full document managed by the upstream aredis repo.
Installation
yaaredis requires a running Redis server. To install yaaredis, simply:
python3 -m pip install yaaredis[hiredis]
or from source:
python3 -m pip install .
Getting started
Tip: since python 3.8 you can use asyncio REPL:
$ python3 -m asyncio
single node client
import asyncio
from yaaredis import StrictRedis
async def example():
client = StrictRedis(host='127.0.0.1', port=6379, db=0)
await client.flushdb()
await client.set('foo', 1)
assert await client.exists('foo') is True
await client.incr('foo', 100)
assert int(await client.get('foo')) == 101
await client.expire('foo', 1)
await asyncio.sleep(0.1)
await client.ttl('foo')
await asyncio.sleep(1)
assert not await client.exists('foo')
loop = asyncio.get_event_loop()
loop.run_until_complete(example())
cluster client
import asyncio
from yaaredis import StrictRedisCluster
async def example():
client = StrictRedisCluster(host='172.17.0.2', port=7001)
await client.flushdb()
await client.set('foo', 1)
await client.lpush('a', 1)
print(await client.cluster_slots())
await client.rpoplpush('a', 'b')
assert await client.rpop('b') == b'1'
loop = asyncio.get_event_loop()
loop.run_until_complete(example())
# {(10923, 16383): [{'host': b'172.17.0.2', 'node_id': b'332f41962b33fa44bbc5e88f205e71276a9d64f4', 'server_type': 'master', 'port': 7002},
# {'host': b'172.17.0.2', 'node_id': b'c02deb8726cdd412d956f0b9464a88812ef34f03', 'server_type': 'slave', 'port': 7005}],
# (5461, 10922): [{'host': b'172.17.0.2', 'node_id': b'3d1b020fc46bf7cb2ffc36e10e7d7befca7c5533', 'server_type': 'master', 'port': 7001},
# {'host': b'172.17.0.2', 'node_id': b'aac4799b65ff35d8dd2ad152a5515d15c0dc8ab7', 'server_type': 'slave', 'port': 7004}],
# (0, 5460): [{'host': b'172.17.0.2', 'node_id': b'0932215036dc0d908cf662fdfca4d3614f221b01', 'server_type': 'master', 'port': 7000},
# {'host': b'172.17.0.2', 'node_id': b'f6603ab4cb77e672de23a6361ec165f3a1a2bb42', 'server_type': 'slave', 'port': 7003}]}
Benchmark
Please run test scripts in the benchmarks directory to confirm the benchmarks.
For a benchmark in the original yaaredis author’s environment please see: benchmark.
Contributing
Developer? See our guide on how you can contribute.
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 Distributions
Hashes for yaaredis-2.0.0a3-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1d269b16da530577d3a73c75f922c95c89f5e9f04d717f82698787ac1e51e85 |
|
MD5 | 925f77d352f30f87a97cc5da0d0d4391 |
|
BLAKE2b-256 | 1bfb4265e9de8be961993a0bdebb90b6433796b0449c819c96b829abd9527d84 |
Hashes for yaaredis-2.0.0a3-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb8f80f1db04b74028744500d9a69fb1606834272aa2a537c82a5961b1868ac3 |
|
MD5 | d597231330ec84b40457862907976436 |
|
BLAKE2b-256 | bf24e25a72ea3e80f4b567437d1364fa59bfd46532fad75de8089dfafdac2802 |
Hashes for yaaredis-2.0.0a3-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d526b29aa612143ad87f10afc4452fa84e4ddcf8f45e6da98ed935caa0ece8d |
|
MD5 | 47be3420d8567847db617eae76c53af6 |
|
BLAKE2b-256 | 7c9cfbec0e0e1de2c3354dfd95eaa0e30ff9f3120f47a4cb7ad78df1449cd8c9 |
Hashes for yaaredis-2.0.0a3-cp36-cp36m-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50899a0005b576c25c153b3df942ad8723b2dedcb498388797df3dc7bf72078f |
|
MD5 | 9bc94e37b03be1f196a3196c47bcc485 |
|
BLAKE2b-256 | 62c263917d849e1beeda81ae6d8068652c63930d25160e2e83374818ef9f93a1 |
Hashes for yaaredis-2.0.0a3-cp35-cp35m-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f78c13534cbd9ec742e41150e1d408efc3d5dd8ff7e3c185d824a78f1a146771 |
|
MD5 | 93d3681ac883a647777bf20201ffaf7f |
|
BLAKE2b-256 | d99b29b7feffdede489525cdabe8e6deb6891430232b45c13a7e855ee07cefa6 |