Python async client for Redis key-value store
Project description
coredis
coredis is an async redis client with support for redis server, cluster & sentinel.
Installation
To install coredis:
$ pip install coredis
Feature Summary
Deployment topologies
Application patterns
- PubSub
- Sharded PubSub [
>= Redis 7.0
] - Stream Consumers
- Pipelining
- Client side caching
Server side scripting
- LUA Scripting
- Redis Libraries and functions [
>= Redis 7.0
]
Miscellaneous
- RESP3 Protocol Support
- Public API annotated with type annotations
- Optional Runtime Type Validation (via beartype)
Quick start
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
Compatibility
coredis is tested against redis versions 6.0.x
, 6.2.x
& 7.0.x
. The
test matrix status can be reviewed
here
coredis is additionally tested against:
hiredis >= 2.0.0
uvloop >= 0.15.0
hiredis
if available will be used by default as the RESP (or RESP3) parser
as it provides significant performance gains in response parsing. For more
details refer to the the documentation section on Parsers
Supported python versions
- 3.8
- 3.9
- 3.10
Experimental Backends
coredis has experimental support for the following redis compatible backends:
References
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
Built Distributions
Hashes for coredis-3.9.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b08539fb99a5c965eddad92f44ed1712517f91da69fe0736cd856ef57dc5fe43 |
|
MD5 | 77131ca2f3c0211af191ff88b27b52f1 |
|
BLAKE2b-256 | cbc19006d7dec9187928c707355f53703ab54712f3fd27c6d1fed4fb9dbf57d1 |
Hashes for coredis-3.9.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab6598f2e448d1d50683a27dc788f502327103b88b930562eea1f26407e5ce3 |
|
MD5 | 47abc95b98268a851d425a138018f5c7 |
|
BLAKE2b-256 | fc953e9130424f7574ba0570176033504a2f5b7237cd0f6ed8fe37ba7b8afd10 |
Hashes for coredis-3.9.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14d26ee258ba66a31c10ea7f146ee151e15c60c65593f12fc949ea78a192a03a |
|
MD5 | 28c83d6a12718c0680b3a127f66ff300 |
|
BLAKE2b-256 | 8e16e4facfc2e1abe3e2fdb2bc55a2501f5dc7eeefaa8fe650c6760c19f593ff |
Hashes for coredis-3.9.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6d10c69d7a0fe071d87afff1934e4a6c371b28d1101e717825f436ad4b7b09f |
|
MD5 | f2da6821ec7f04383ec6b488ce39d470 |
|
BLAKE2b-256 | 0a36c519f1c1837fd8327f49eee906b9eead2a551815a88b15636cfaa52d9905 |
Hashes for coredis-3.9.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8eeae42afdaaa4b25b840c4321d2c20c5ea4511cdcc6545a5aa9a1bb4e10fb0f |
|
MD5 | b47984f102e7542ca9caab4cd505c545 |
|
BLAKE2b-256 | 694543f96adb7d3dc932a402ccc42d4e880a56e74852a634db825a2e3d28a04a |
Hashes for coredis-3.9.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63aea6d59b5258ad36e5edbf1933a44ebaf6ee84a14fbf14ab79b96e3b381426 |
|
MD5 | 7647731ce6754173ff7c19c0a11c3b22 |
|
BLAKE2b-256 | 7f795f1c07b94dec430d5e14fc9b73c0f644ec4e7f779d4bad9660fa747902b0 |
Hashes for coredis-3.9.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68570082ca3c07b6f2776dd77804dc2509650ec68f05834819e1f49891ad9d27 |
|
MD5 | c23c5c290aa20128cb803e0bbb248d0a |
|
BLAKE2b-256 | 1b062e98d30b25cc26549f2b24e76bbcb384f0030a3d9627065b3847dd0a5b6b |
Hashes for coredis-3.9.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5e2b806f8f6737567f92b5c621a7cb49977ef767e6188c447a6afc3ff1121ae |
|
MD5 | 1f53a7c90357ee6014e20b2e2acb03da |
|
BLAKE2b-256 | 650f78cec46161814cd5c815bd84021454651d0dea61e2590c61dd1d11a7826f |
Hashes for coredis-3.9.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eccd44d608b57745a31ad892269da9998a6ec14564f990a6b9e5757de0157909 |
|
MD5 | 5c3638d19b3a5440a259aad27ae0dd9a |
|
BLAKE2b-256 | ea51955f57acd44dbe22b081deeb6c06233b72692d160887a0a67cd214fc21cb |
Hashes for coredis-3.9.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa4a6f83660b9e25eb4e3d22ee12eea8fcd4a77cfa8e7eed0746259c6f2df135 |
|
MD5 | 057fb37507ab3daec758aef8db1195a4 |
|
BLAKE2b-256 | eba97a98114ce8d54dd0a3454e55134e1eba17af3f3b8dfbc4a6db272cb8c6c8 |
Hashes for coredis-3.9.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15caa0749607ec0b4b0a089fe7d98d92c863266b9f7254b94d53a1301e8e3a10 |
|
MD5 | 818a21bbce58da063a5b2ed509b046aa |
|
BLAKE2b-256 | 0958236a7f93df94470a686e32577772ce56b49a0e830e65f05097f147cf06dc |
Hashes for coredis-3.9.3-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fabaa69d496419e7d49ce7f1ec2248e0bc3b1700799d1b6bc6f0b72ebda0142 |
|
MD5 | 9f3977d6b07e9b55af2843b91f252de4 |
|
BLAKE2b-256 | 9de47a1255469926f51b3ac80c063f52fcf08bb65ae9920a2f503fef3443a910 |