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.6.tar.gz
(154.4 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.4.6-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2e4ed1e5fc14c8866296a0df80a687b8c5f651dabf9d1c462ab5167ad61effc |
|
MD5 | 339c66edb27b5a212437cad78f6bf5f5 |
|
BLAKE2b-256 | 9ef8f2ad5cd947d1dea2c90d6e8f95b697403bedb1950d01f4ee835cc643eed3 |
Close
Hashes for coredis-3.4.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24a6e8c9ba7ba99359316cc12af936044c9e5a7bdef559a8dcd2b924b29c79fb |
|
MD5 | e9d307d4ccdcb88eeefaf095ab05cbc9 |
|
BLAKE2b-256 | 377b14e15c7eb57e84263caffdbbddecced1fcbed5ad19d3b4645f1a93bf4a3a |
Close
Hashes for coredis-3.4.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d6e407c9d2112534093ea21a656e5c610cff335883f0a06608aeb80e45ae10e |
|
MD5 | 9ca89f2e93895934b3f660b49663ef82 |
|
BLAKE2b-256 | 01ba99096fe86b11c0f03c1d360c8336c603f36c99b66b6c896fc936a9f099e9 |
Close
Hashes for coredis-3.4.6-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32cabdaa6e90acaa7e7c5bd59122bbdbb2addef187052cdc882c367fb29e73b9 |
|
MD5 | 55b80c9817d3380af81e4fb5106acd3f |
|
BLAKE2b-256 | 9f3ec118032dd72905645d36dd548906d9722699c5cae6d0477c2f43c23ab1ef |
Close
Hashes for coredis-3.4.6-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b15d4fe74905b9ab0e5fa825c4085d6ab901127b2b1f39d516ed1e5d9634e222 |
|
MD5 | 1fcfe651634745816a630a256d7bebe3 |
|
BLAKE2b-256 | e3552af920d747741ac70bf1a608a5f96845f3a12fdba90da6a4db9b9ebe2e64 |
Close
Hashes for coredis-3.4.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c9d9d092a3b37f61de0b3c4078e5f427c2cb7a409afdd779204f99a47a1b793 |
|
MD5 | 45af48eb3b9b4efea2cd2a1237cb4a8c |
|
BLAKE2b-256 | 9844d6155d122c48ce1934068f100d7fc4e94effbcb72ad3d75033c7b970495e |
Close
Hashes for coredis-3.4.6-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8f8cf7150b374c8226acffee28c4f4f757d2e9c90ee57c6c5dbf772f1b0f147 |
|
MD5 | ff09e62b0930f25d61493a89d807c727 |
|
BLAKE2b-256 | fe22e59f61f57b393c15a7a7aea82b44b17b47d8c99be1de849b13da98a089ca |
Close
Hashes for coredis-3.4.6-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c5c8881b0dc1c4341a0a969451f51571c508a95eda536684f263a10ab9a6222 |
|
MD5 | faf8f0e92444c78b1e249640780e9a6a |
|
BLAKE2b-256 | 6dbc90f21c00df7ebd088ffbca2fc344ceb98f7e763d7fb0cf8d134eeb28e8c4 |
Close
Hashes for coredis-3.4.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c24a13ec3f26ed58e534bb6b2f8552fe743b960cc4653be960e35f4ce1b62af |
|
MD5 | 5df0e63355dfd1074708e76ad8a0384d |
|
BLAKE2b-256 | 527f11ff8c9520ec578d1918d0e2d1db33f0751dc64b1017b419703e4811191a |