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.7.tar.gz
(154.5 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.4.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f568d730b08c8336b19c891e5ecf780b7a3634fffceba895674f35c1062d3f38 |
|
MD5 | 4a747e214e81b8289e88f38d302d82b3 |
|
BLAKE2b-256 | 13757922f422367462f511f58670b9ec91ff7b776bb9dc134b1a7f21da700a24 |
Close
Hashes for coredis-3.4.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d85998d78de1325e30375ee9196a76510bb6283b5abab523742796c460238d5a |
|
MD5 | 81e7869992c0cdb406b0f30d3aa0a73b |
|
BLAKE2b-256 | adb464e5668c6df6c9a3050c78cdff6263478180748879bf9acdc440bcb78638 |
Close
Hashes for coredis-3.4.7-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9267a54e74b7498483f3f0a65e0a2918799edeaab8464c95d7e698660f7779fb |
|
MD5 | eb6154d777edebb23d58d6d26e4ea18f |
|
BLAKE2b-256 | f79672e2813466bc9b76754e4b50b437bef2d59760f05691d0880b1f5abf66d0 |
Close
Hashes for coredis-3.4.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ef547c5f64cf4abde5e094170571fe49dfb111ec15026e88e1e999a0b803051 |
|
MD5 | 7971f81ae12d487c2573b3915f92ae48 |
|
BLAKE2b-256 | 5d0f874ab07d6a3375015ea0ccb9e37aaf365012dd7d75816a6a353643b214ed |
Close
Hashes for coredis-3.4.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd091f8d12b0870148cf8e119e3778ce95b5826977c64f67f41db7e64c2c1bc4 |
|
MD5 | 035f54ac2caa16d4cd1421f008c7bd64 |
|
BLAKE2b-256 | bb401dabedee0bfd73ac06e1dce2d8a166d3466208faa2d99c332265eacda357 |
Close
Hashes for coredis-3.4.7-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a995a8322eca8bfc537be4ffcfabe69a9fb8aaa9d2b6b1baa455d658a2d82c5 |
|
MD5 | 976227efabfb30b4e3669a3276aeb708 |
|
BLAKE2b-256 | fb1177225b7cd913f82ecafc4c0287910c8043b6b5656ddb3bd734a31778ec77 |
Close
Hashes for coredis-3.4.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f1b3d221ebd819d555095344e4cc265580fa89a47ed7e1ecd2f6db00a612c31 |
|
MD5 | f02cc61cfa3f8c248b8070bad9633600 |
|
BLAKE2b-256 | 1b7683102b963616179a7db8390236f1498c36c1fcc2f110424e777ee10ee61d |
Close
Hashes for coredis-3.4.7-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d905460dbd733df0883b254e8edc7b10c8b517b820fe87bb36067a309bde95d8 |
|
MD5 | 4687e67727a9c9f30a916b28feae1ed9 |
|
BLAKE2b-256 | 1afae99e7f679a031b30e59c396cd067147956fb2b3086782539115b8e00d2b3 |
Close
Hashes for coredis-3.4.7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb4eb881e4642778e437e258a8e3543e8fdd9cfb80a6b4084d2229fe5f3ece28 |
|
MD5 | de2cc7537f333b86be93840fae9cdc4f |
|
BLAKE2b-256 | f3a7cad0af484b0e472ef4a321e736ebc6723c3f739bc34dad778fb221a369e3 |