Python async client for Redis key-value store
Project description
coredis is an async redis client with support for redis server, cluster & sentinel.
Installation
To install coredis:
$ pip install coredis
or from source:
$ python setup.py install
Getting started
Single Node client
import asyncio
from coredis import Redis
async def example():
client = Redis(host='127.0.0.1', port=6379, db=0)
await client.flushdb()
await client.set('foo', 1)
assert await client.exists(['foo']) == 1
await client.incr('foo')
await client.incrby('foo', increment=100)
assert int(await client.get('foo')) == 102
await client.expire('foo', 1)
await asyncio.sleep(0.1)
await client.ttl('foo')
await asyncio.sleep(1)
assert not await client.exists(['foo'])
asyncio.run(example())
Cluster client
import asyncio
from coredis import RedisCluster
async def example():
client = RedisCluster(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'
asyncio.run(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}]}
To see a full list of supported redis commands refer to the Command compatibility documentation
Links
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
coredis-3.4.1.tar.gz
(152.4 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.4.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e8f2b142114810e6744d4d6720ed4135e79e5f06372bb21a8f118501f810345 |
|
MD5 | 34e7a6c889c200fcd8af897cb5e9d840 |
|
BLAKE2b-256 | 872617d8114b336500c5ef62807587221a4064f261c07f658f3e19097157a2fe |
Close
Hashes for coredis-3.4.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9276f115e66737d3d676f6072afdc7dcbf17d9921d4d4b27361d26ecf69d3721 |
|
MD5 | a1778a664c3bf334e4afd933116b5639 |
|
BLAKE2b-256 | 3eac65f2e6238cf0a0dc508fce563b54e1abe9961595968adced891cb4fd5233 |
Close
Hashes for coredis-3.4.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf9e0ae156e7feea9715f438ffb8f2752b0341b7302fbf69b0e9a81c5a69ed4c |
|
MD5 | 8d9b32aa88049a82527a7d8527b49b3d |
|
BLAKE2b-256 | 3e0aa0629cba6270e272b8aa0537e3b59e814179ec30038eab36c033568f6079 |
Close
Hashes for coredis-3.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cab37989ad03407620f368d123acb652cc70765d3c75388c95e3212ba8ab7b5 |
|
MD5 | 64abf424ba1abbb3f64ffb96d39f31fb |
|
BLAKE2b-256 | bd8d0ebe799a1d30a9a74393f04eb5713e90b4b9d9c9dc1884f3fcecec86ce53 |
Close
Hashes for coredis-3.4.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 384ac65a1d461f593436af3f8d158de35bf67ec9e500b9c6e5c6d76f8f831d5d |
|
MD5 | 98f98414cdb66690aab404b8115f4fd2 |
|
BLAKE2b-256 | ff1b96ba3899a6f17227c1933ac17eff8b332a4ab54ead43836e9756aa5d13ee |
Close
Hashes for coredis-3.4.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5af8a197c3094843beee46257ba98d3dbc2e894641bedbceeb939cdad0be859d |
|
MD5 | 7f297a30052a8e810d1920a24bfca897 |
|
BLAKE2b-256 | 57ffa6224468a7fbb4f0998bbf792ad36c51a6566d9187e03f4ba9cbf895ecbc |
Close
Hashes for coredis-3.4.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49971df7d4c25555fb47a8951f480c42f7a6d501b9b0c72b49b36ab9dace5038 |
|
MD5 | a69565a0d1c8188afd5ab1d6384cd2b7 |
|
BLAKE2b-256 | ad0640ecb74ec0641811e7ce42f880d8b0820418c4636511ba4a77f33da7914d |
Close
Hashes for coredis-3.4.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86f4469372a3d166fb906ebc438451817a8d005702e3084359e1b377455d1e7e |
|
MD5 | ef37c3e165a37ab467a1d090bd619dfa |
|
BLAKE2b-256 | f90545909f11523388cb5e8e015701c01217c6b54b32ea8286d1fee62ff02f61 |
Close
Hashes for coredis-3.4.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdfc7814b84fcb84c6de8702e1bf987709f99509b3556ab1cc2f932b247fff1a |
|
MD5 | c3c74c1e5f7a383960d3f17c2e58c158 |
|
BLAKE2b-256 | c100a9a92e6cf420d2b25c5f8c1a7225a6ddb966957df8f6bb315ca13c0d7855 |