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')
loop = asyncio.new_event_loop()
loop.run_until_complete(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'
loop = asyncio.new_event_loop()
loop.run_until_complete(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.3.0.tar.gz
(152.7 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.3.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86fc607662464d95082bdeddd71431a36363167b454d34213b3d1737355e46fe |
|
MD5 | f9732b7e3629d2fb0d5fbca65f8eaac6 |
|
BLAKE2b-256 | 4eea856cf54ff9c268c31434c6fd4c3e472f628ac92f641011966e243ec26485 |
Close
Hashes for coredis-3.3.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fc5afd6fa16812bfd724d282b7b18be6b4e77d941f37da805ce7f2d6c7b6ceb |
|
MD5 | 59a7bcc6f68a7734abdc7027889a9e60 |
|
BLAKE2b-256 | 1f392dd030a4981b25ac68ced909d2226e3764b9e5d58ebec1d3860391aaa429 |
Close
Hashes for coredis-3.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dae30e2fc1f91710bac5be3b3b6e19baa4a906aec9ef7d9bca7eae9503099dac |
|
MD5 | ea754bdbdfbc42ee66afdc9da9a2be99 |
|
BLAKE2b-256 | cec237a49f3dd27b83001acb5f526dc95e726195b204173ef1814a4a7b670b2b |
Close
Hashes for coredis-3.3.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df0dcbaf81582e62450fd187e4a4c28e37882ac67cbc5d2eb8da8f2ef7838050 |
|
MD5 | fee69a7b24f685781919e9d5241bc6be |
|
BLAKE2b-256 | 75bd9f475b864bd20f3df2d9ce7a4d4b1a1ac0bda3228aa907b489013434290a |
Close
Hashes for coredis-3.3.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a70016a05f35e9b0159a54754943dbfa03b6c93cdf841fae41ad38c74d5b0e3 |
|
MD5 | 3ca403d9df77eb3317c3158654890eb2 |
|
BLAKE2b-256 | 68b8ac20e73ddca031ef90582f93481170e2c3a4cdc0cacdc7020e012fe56075 |
Close
Hashes for coredis-3.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f3d27ee4befc058f54fb2d155d488e99c2e9f7ef31f1aecce9cc438b595a4c4 |
|
MD5 | f30abc982c86e11d101cd16b44f5db81 |
|
BLAKE2b-256 | 61c55746dddf05ad9fb706dc1ff0f8f1144c9237b20cd692c59b1dd24841bf3d |
Close
Hashes for coredis-3.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e378cc867c1b0d929044cf49d866f322a6259871964b6a16ff8f482518a646d7 |
|
MD5 | 76e1583f8f15eea3d8593caea8966aaa |
|
BLAKE2b-256 | 238c045ae878c88a71206fee8786bb43dd8f6c8a4cfdc0b19d63b1409ac7bcef |
Close
Hashes for coredis-3.3.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97faa66b290f40081c4c65eae65ee6dfc93ad15cedae7bc0d9baecc9600676b2 |
|
MD5 | 1150f14ae20aed47cbdd6a8a964c12ff |
|
BLAKE2b-256 | d09516aac53bb923487f5271e5f8187519360f25b7aca1c6e3be9d6516c2378b |
Close
Hashes for coredis-3.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5d867fdc9221e00911ef50289533ff8ab2c76b8e07a25238a78375faaccdb82 |
|
MD5 | 6118ee1573912b8faaada818a677f7d5 |
|
BLAKE2b-256 | 2d0112f095e6f27b229fa0bba008d37af14240d7a81ceb5012f34125b1167c4c |