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[hiredis]
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.0.tar.gz
(152.5 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.4.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0e242b3fcbee198c3a0d6cdf6651fba156a33383f5b6ae1762000c8c12b296e |
|
MD5 | f6ab0ca1660afb027b5c6a3f0b761b16 |
|
BLAKE2b-256 | b66b8fab3df52caffb4d95a17ae8db788617826cd4a2aa8135593ae9ccf239cf |
Close
Hashes for coredis-3.4.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1671fd01671d784d1712caee9a2b97b7038bec073d76b41f4fa4b3f71b540fb3 |
|
MD5 | 058cb53f110f91bf19f4c4b8a830e960 |
|
BLAKE2b-256 | 1a34c2a64e64d1f533dd849b32a0bf751d2122cc82babdc3d1f9f6d942298e00 |
Close
Hashes for coredis-3.4.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b031691609e033cb353b79c8ba5ce5398d3a6734096a128c45c22f0dca205591 |
|
MD5 | d06d7f4ca7f8be00cb9196e819d2e5c0 |
|
BLAKE2b-256 | a0d49f26ea9b4ff32e6888557c3e7ebdfe747a54ca43beb30d03a66d2f6f3b8f |
Close
Hashes for coredis-3.4.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9412d602a26cd2a1e8c5c3c965c7822643c0390abfd0d01406b5ded8b21503c |
|
MD5 | 46bd5f9c39f6329d6ced35f0af5db834 |
|
BLAKE2b-256 | 217c569f6c7b633286b2239eb5fc71755d46f4f06fdf2ba17716324f48da512c |
Close
Hashes for coredis-3.4.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a7e4fcd8d1fbd3b855c7c93296f5a576eef0a5c3f7a79f526b7b3731bd6dde5 |
|
MD5 | a5dcab0a6f71c4648de2e8519a5be388 |
|
BLAKE2b-256 | 4471147d889d9af1ba1c4d192043971155e0ebdc427b552f2cf0a06dad5eb4e3 |
Close
Hashes for coredis-3.4.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92c0ed93093a2afa1c3773b33f372d260eeb793c36e1c0f98f3c56628ccc8cb8 |
|
MD5 | b1c956ef514eb16a1615fc50f9825c03 |
|
BLAKE2b-256 | 130ba2dc03ce0987613c4929ca8932f8c5c4180f416bb42380f9453669b15985 |
Close
Hashes for coredis-3.4.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8729f5580403a36f446a08aad88fb052fa9528dac01aeca65e1da9eb51ec5d33 |
|
MD5 | 9f98d6175831425665b7e6009b085f7e |
|
BLAKE2b-256 | 968e142c29cb166ff8d7b20ef6023a9e6b2a9952d802d378e0ed2eacd5829fbc |
Close
Hashes for coredis-3.4.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7209bd54c455e22c617644cb4a83d96573f7e0601a28a61136de0306e405cc5 |
|
MD5 | e8816d0836cdf0b2063c05a21b701bbf |
|
BLAKE2b-256 | f7baf602e6ce95546de27fd799a5ef370ad5424d8aca46756c01b9e4be073883 |
Close
Hashes for coredis-3.4.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3418d08977e1507a4da826b70b91f28a4e8971ff7218d6c0925ce71f97f07328 |
|
MD5 | 336d58962c02561e7d39915bd558d291 |
|
BLAKE2b-256 | 1b3c032e849fe8f27dd12336907c1114fd6cf5e44e9f017ac496a1f22f61924e |