Python async client for Redis key-value store
Project description
coredis
coredis is an async redis client with support for redis server, cluster & sentinel.
-
The client API mirrors the specifications in the Redis command documentation by using the following rules:
- Arguments retain naming from redis as much as possible
- Only optional variadic arguments are mapped to variadic positional or keyword arguments.
When the variable length arguments are not optional (which is almost always the case) the expected argument
is an iterable of type Parameters or
Mapping
. - Pure tokens used as flags are mapped to boolean arguments
One of
arguments accepting pure tokens are collapsed and accept a PureToken
-
Responses are mapped as closely from redis <-> python types as possible.
-
For higher level concepts such as Pipelines, LUA Scripts, PubSub & Streams abstractions are provided to simplify interaction requires pre-defined sequencing of redis commands (see Command Wrappers) and the Handbook.
It is strongly recommended to use a static type checker of your choice to catch any errors with respect to argument and response types. If static type checking is not a part of your workflow, you can consider using the optional runtime type validation provided with the help of the excellent beartype library.
Installation
To install coredis:
$ pip install coredis
Feature Summary
Deployment topologies
Application patterns
- Connection Pooling
- 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
- 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:
uvloop >= 0.15.0
Supported python versions
- 3.7
- 3.8
- 3.9
- 3.10
- PyPy 3.7
- PyPy 3.8
- PyPy 3.9
Redis-like backends
coredis is known to work with the following databases that have redis protocol compatibility:
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-4.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4713e3a401780245c7a1d2e57c2013362e332c58d0d2985a6dc13c7bb7524d26 |
|
MD5 | 4533c8ae3b402dcba9103a073cae8b64 |
|
BLAKE2b-256 | d299f337c51fb9171fa42a0690f7bb594de8a626c253cebcf8cf16c0733a3c11 |
Hashes for coredis-4.5.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f5a58eaa0882bcfdd73d40fa9dcb2a0385b04c3f1be2aff413814478b3ca6c7 |
|
MD5 | 5ed9ba30bbc8567b7448dbc7c492630c |
|
BLAKE2b-256 | 37c2531668e153108429139ed58093bb182783878a582261a532c78f4dc2590d |
Hashes for coredis-4.5.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22439170b4933218ca6d9c0ab623598543326d2b703e2d71e2ed4f7b1ec4b0e6 |
|
MD5 | 6166d06c4b8ad07b5733a1bad3e8f01c |
|
BLAKE2b-256 | 68e1d1da0256ea5468317240937b364abc93bd4dc20d5d846db8fb509c7f380b |
Hashes for coredis-4.5.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e138156022a085d1a533a6660725dec2bc1e5d3f853dd0eb022a6f9632ec799 |
|
MD5 | 34ee35f6379676b14dfac210ec7c2b3e |
|
BLAKE2b-256 | 060d10531b0bd2e198426fb2b230ca59f321b168879b491749947a96a5d8b0e8 |
Hashes for coredis-4.5.5-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c68332760451937a5a123710006469fad5ee6c1f30d6d19e581dcb0f89a9ef6 |
|
MD5 | daa87836cf73f829717aa676c0f74ff8 |
|
BLAKE2b-256 | 144d51f7e2aa7badf5f06a9c80f5455da94ca01d8ad2cb3faf22ba7049d7c47e |
Hashes for coredis-4.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0f143f4b38019078f1c403ecef00a48a2b392bec1ac78b84c5a8254b698c94e |
|
MD5 | c43b7d9e297069918dc0c2dcc9573b88 |
|
BLAKE2b-256 | 38134f2a47f54622228bb46e7a9c74218fb0fc5b3100ae08ca71e1d37d40865b |
Hashes for coredis-4.5.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c421462a5f71a8da514b86102f60bd3eb9407b3f71ed1f1523a0014da054d7c9 |
|
MD5 | 5ec22dc2f08a1bf7eca26352a14a5c09 |
|
BLAKE2b-256 | 46c4f93281327b471419f2e593688d55c5ba3b85b79078e4b166ea056fae9fd3 |
Hashes for coredis-4.5.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9963f8e1ed9a9cb66e2accfcc0b52d51ea80fe319ad66b6d92fe618d06c33c8e |
|
MD5 | df259f9163e1456c16c351099f4039bc |
|
BLAKE2b-256 | 0d063b691c322a2b754279e18b1ea2228656f42de0415fc5da675a7169a09d6f |
Hashes for coredis-4.5.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bafbe27c684fa609aa61d68108ac4f8637e0ff5c8d9e45b5b91e2ffe09f38c5 |
|
MD5 | c92568a43bf1d3d90d8f0edb4c31ea00 |
|
BLAKE2b-256 | d76326e11c731555eef23ca6398969f67934d430af9360dcbe694d17d8fca740 |
Hashes for coredis-4.5.5-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8e1158cdce067376f519c27e3a2bc5eae37f7c15d0dd7d45debfe0c26779562 |
|
MD5 | cf3da87d6eac84e01886fbff0b1db07b |
|
BLAKE2b-256 | f7d924bdd7134dba5b4bbab435e2e841afa7c8d12295068a2f8f914dceb63076 |
Hashes for coredis-4.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f6b3ae0d535214415bd7043984b5b74da7453bc51550ece53f97e81d3d044b |
|
MD5 | 1425f26308ed497b3c37bbcdc41d2a4f |
|
BLAKE2b-256 | c6483a8de26931448e545f84322ae67fdd76af19aa90ff9ca0d883a371fc9988 |
Hashes for coredis-4.5.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac565f9088083025411ff17b6d2dc86887a8c6d07abd2234fd5eea3021da458d |
|
MD5 | 7a98df191c3899315088b2b6c4b2a254 |
|
BLAKE2b-256 | 272a01c74a6a12de02f910c7f11870732dd7c3ed39cbf8497b0d1460a93d9533 |
Hashes for coredis-4.5.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ee6ee61857e0190f3055dbad3ee2438fb251247f00805e1bceca2c85784fec1 |
|
MD5 | 04fb1e4b65725a89919cae0fc862b7f0 |
|
BLAKE2b-256 | add077cf3f5c70bd64b630a7021364d4ae046b8f9b71ac6dbfe3c94ff63ce2a4 |
Hashes for coredis-4.5.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9052029e53ff42c6e017ce7bbc186f3e9c12a41b4892b9fba5db9dd89a61aae6 |
|
MD5 | 84d8f28612a92b913f79ab6501422264 |
|
BLAKE2b-256 | 0156f2bc75811806079810032427837610f6bf85771450a25ad33ec1a633be07 |
Hashes for coredis-4.5.5-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85e5d2cfb9d0b1a74e3027e4f80fee73cafb3bef5e26877484fb8d0aa96e9343 |
|
MD5 | 9002a3434d373c2f6fab37cbc47498c3 |
|
BLAKE2b-256 | 764fa469e05b41037d156d7338edc4f3af8d1b9eca84316a9db2d1941dcfb17a |
Hashes for coredis-4.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d36d153e55b6bf23e3a4b350f464424ff5a1f9d6e2554dfa84ba0f9c232e726b |
|
MD5 | 933dad2cdbd1b5e4cc7fa2a487325948 |
|
BLAKE2b-256 | 2a227bdd8ee69f4fccf1aeefae5ca26ca06e78eecfbd1abcb6dcd8675bc45dd7 |
Hashes for coredis-4.5.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cf67caed3ec8d039ee1fc15bc22ceb551fc0d5a28d09e49b855ed2c9da9dbe1 |
|
MD5 | bd2613d69e111a0a537312a562d4977d |
|
BLAKE2b-256 | 111699d869516fc73d0aa2c265096f8513a759ca519e3ad755856974d32cc8d7 |
Hashes for coredis-4.5.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93d00038c74641797ed77907eb41b6caf7dcb29a6ec382d062db9edb9f4c416d |
|
MD5 | 2ec5ce4bc8f5160b8a66d92bd1851fcb |
|
BLAKE2b-256 | 622801242dd43be80879c183b71e5672d01865dad513c6e2c4fe22c51e2b4b1a |