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.3.tar.gz
(152.5 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4befe593b391fb6e9c5f445d1d3107b3ec4c690a8dc70c7f6be75b8e92bf9ad |
|
MD5 | 3b84cacc0eae5b4a983383b42e957745 |
|
BLAKE2b-256 | 768d99eaae02d6ef5400b994bfc49e77c1acd0d556bef5b5017d7c0af31ec415 |
Close
Hashes for coredis-3.4.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99f0cc7bbc83b45718fc1beff52855ae434dab5c20b5a614c4b69f7b04fffd08 |
|
MD5 | beca2517b26516357fd397a056975298 |
|
BLAKE2b-256 | de646f3b2f152e5b028cd5670ade561e7db96f65898fb2359c229064bf70a649 |
Close
Hashes for coredis-3.4.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4987837283f47bf505c19bb5847e7059160b0133635ae4e31ffc21c2e691835e |
|
MD5 | 6958b5301244115192f432f32ff0f8f3 |
|
BLAKE2b-256 | 3950b2ad427015b3ae892a565f7ef26e09c8efdddc47033065cbd29b697876c6 |
Close
Hashes for coredis-3.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cacbb7ec83449a7f99cc0f8812deac315b7e4c6359a05b4a1040d8db491ea0ad |
|
MD5 | c6a27884cc87bd17a27876bcf5c493d1 |
|
BLAKE2b-256 | 88518dc94901ebc6cdbe5f6bb328b9e15ccb8f4d5e9fda451bfd7424e8b4fbc1 |
Close
Hashes for coredis-3.4.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0329414ff5977b10ee554e7857ad1a45451f29b5eb1d340383cdbefeae0c8b79 |
|
MD5 | 44fcbc37f2b0902879e4d239ed35f2c4 |
|
BLAKE2b-256 | 5aa86640b20f35e99870781345ee757cc0ab01dd4c1c9ecb392adbe25eef2682 |
Close
Hashes for coredis-3.4.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e3acf1a77b72c0b0c1e216ab366b8c1768694e22a4f6a8a7c85db6ac6b7b669 |
|
MD5 | 765cce20fad04c4345f7d66995340108 |
|
BLAKE2b-256 | 9abb605e6a2602e008ff6e38bdc8f2eb5d2b640dc6a4239a481ce1d83f830a8c |
Close
Hashes for coredis-3.4.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79eedf588d8e5df9186f8ab9c4de931126fae4ac809cfcdb58a5f3b5f3aeafac |
|
MD5 | d6af66bb461038e8c6d82d1a45d60905 |
|
BLAKE2b-256 | ce6b25ea34977509b217e47b04c8f52d09c1194103c9d7d4609cf15c91afb36e |
Close
Hashes for coredis-3.4.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f999bbe8e9ba9cc35b58ddea2fefd012ca6a3e294414958b0ae9f1b04f64c97 |
|
MD5 | 947e684c84189c180fc65ff38b164611 |
|
BLAKE2b-256 | 0743c6cbbad01bb0ebf23f972b7f515333dd3a099af54819bcd3bc0fc579b12c |
Close
Hashes for coredis-3.4.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c35107265aefdedc57852e5580c509752cce1b86d4ac698f270e63c9e75b514 |
|
MD5 | 42b2984e73a50892a05a4f8799f1f398 |
|
BLAKE2b-256 | 98bc64f1ac8ea37aa3f5c0cc66ff884203561c499084361230e7d094a577d7a2 |