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.5.tar.gz
(154.3 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.4.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fc875ca669ca742d0908252224dd04b75b9f67b320e750aa04b13f719f4c74f |
|
MD5 | f0f1a0deee656b6983998abc297a8313 |
|
BLAKE2b-256 | 0e36114f86b9abc8f47e27d6f6921a84cda88460f9f3258929fadef68dde6a38 |
Close
Hashes for coredis-3.4.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20a06c7373fbba77c2179d069da1c6dfd38af7218e54a6caabccefbf34155ffc |
|
MD5 | f3f89443860f20755c935a51871bb1f4 |
|
BLAKE2b-256 | 1c85989941c68b006f06124ba6f54a94d6daa1ff03750c24edc783b18f2e8630 |
Close
Hashes for coredis-3.4.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bafb0e98c7cf580a7b4f79524b1e88cf6e7bcb3970eff0909856838055eb8884 |
|
MD5 | ec627c5752d5d0362bab43130041ea8e |
|
BLAKE2b-256 | b5daed93866df30c1b9c8c7952a4162897e44cbb5d835f4ab5103b25c9916588 |
Close
Hashes for coredis-3.4.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ce2bbfad9cc2e32da6fc9422c0d5111486220791fc0f9c4e832596547d17cd2 |
|
MD5 | 656daba00141901372fedfe071e7ed80 |
|
BLAKE2b-256 | 1561b17930a9575ea00f4e327d50224ebacde8a5e5298088ae077c4f1d239541 |
Close
Hashes for coredis-3.4.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba28b9839a15c1f6b92dc840222e567ce5c4ff0f744328914d93d70a6fe566b8 |
|
MD5 | 4f7f9d324df78de902a634b9837ecc5d |
|
BLAKE2b-256 | 0292322790fd62affe92e8a756d9d14e75fa9739b13350bb1d65ba9f69dcaa90 |
Close
Hashes for coredis-3.4.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff77b77503fa84b3c95043bd31b19e59942e723853ffb48a56fa6bda7cc401bc |
|
MD5 | f36074f9e39a2fcf06ca1f60e2738947 |
|
BLAKE2b-256 | f92f90f97e4605a95c173036884ce1022d75c1f17938d31845ae5ed1d66b9fa0 |
Close
Hashes for coredis-3.4.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63765d34382ae11ea9d817e3827a29c49a96ce0c38a222e85bc07c038a082da5 |
|
MD5 | e5ca79ad5fe6cf0bab2439e26734af93 |
|
BLAKE2b-256 | 4d008c0583975b61b0b08703a2e7128d6795a95e4bf927a79a68ba076dc932fd |
Close
Hashes for coredis-3.4.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bcad1e53a739bc580e8fa4d4ff57c2ed2e3d241a7280ca5e72071478f09393c |
|
MD5 | 243b9092590faf5028a799d1c182471e |
|
BLAKE2b-256 | c0c43d148e3d3d0fd15488b7633fc0d5d9543d3dc27e88819eead360ae01d725 |
Close
Hashes for coredis-3.4.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa3c238223acf8d008955e52340bb0bfd078a61f19f4146d80cb70953bc92858 |
|
MD5 | 5fcd6b86ae5ff560a4bf2a9199a2b2f9 |
|
BLAKE2b-256 | adae3f6186c98755b464980de7ee5f75dbcf48019ba52618e0196bf8334f85c5 |