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.2.0.tar.gz
(150.5 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c478cb70ea31d139f3d409aa6fb4a7c6577541f966f2ff3ddc643ce958b5569 |
|
MD5 | 44627294ec33e4e8b2db90bd7962f45b |
|
BLAKE2b-256 | ff01cfcc3823022bcaa9aeddca53e512ab87e68e9bdda5a407e57d8206653f3c |
Close
Hashes for coredis-3.2.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0193cbe62d0e853365e1ab35b5ba86d363d3bec965b74524fe34f9a52703ba00 |
|
MD5 | 2a40ff7febac5b2d9e1a497b3aa9eec6 |
|
BLAKE2b-256 | 131fffdf8bf4ef01aaf2da80ac451eca03506de19ba166d1b5c8909682ccb7d7 |
Close
Hashes for coredis-3.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3126f1906e584b1054bfe659b3c14c78ca84d39a5986ec4f568f8dd00f21d39 |
|
MD5 | a6806fcd1de0bd94e0ec2944e953d564 |
|
BLAKE2b-256 | 2e2719f6b69ceaaf9c881f7702a28abd0eee59cf12c6fe99b2fb8646e1a50aa3 |
Close
Hashes for coredis-3.2.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 428a86f721e88511a5c5c6c13939b4353181e7d47a54b83ccf239ec8a8a3f208 |
|
MD5 | 5c17409181a0e37163191f3c05e1457e |
|
BLAKE2b-256 | b12722f19d086d8c2f2d46531c30409d2cf59e7687338c01837631182c8eff93 |
Close
Hashes for coredis-3.2.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0a0a4307beac4baf2fd7a6ca3a1da7ac5f86d6bdf72775ea0e134ac05b4220d |
|
MD5 | 7f95595c85b5deee9627825a3851acef |
|
BLAKE2b-256 | cee686e683f021d62dba7195459081172b9d3388c107c4e4879c9f2439145ca7 |
Close
Hashes for coredis-3.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c4fe68817762f50827f6e4aee2b441f5bf4687c8dc684dc77fd5322a4e3fa3c |
|
MD5 | e48b44151b28ec0ca55ae818cf61883f |
|
BLAKE2b-256 | 2e4cd2270ec64dd4ef9b7dba1d3ce3cfc11086ec3def66f901219556d3b9c866 |
Close
Hashes for coredis-3.2.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 003ebc8ea4cd12c35f7c042f9d7e52d782ba50e798edd53a364e689cb832e4c1 |
|
MD5 | ed6ec8ad3d03b4cf58f8bc2183ffd50d |
|
BLAKE2b-256 | d54d10093b5ef7b6db6c4156965cc37481e89fd9cb060a0781b8243e8ee055a3 |
Close
Hashes for coredis-3.2.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 724f2761ec292eedfd826472b796e94c59976d8c22d98e6ea7ec247df4b5782b |
|
MD5 | 7646f15913c29806aa303313bd43f664 |
|
BLAKE2b-256 | 533750f0678dc1379db6caf7af79521b56ec6aa0098bcf6867b4d4083f8b92df |
Close
Hashes for coredis-3.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46f6e25029573a5b6d4f548a217b0e748293d1b9d09ff5d76f74449c46629c75 |
|
MD5 | b1a1d1bdc22505a3a36db3f7b02356ab |
|
BLAKE2b-256 | 3f825815466f17937a70787f0ba4695adbfa125838a832d65924f86928476436 |