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.5.1.tar.gz
(166.0 kB
view hashes)
Built Distributions
Close
Hashes for coredis-3.5.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8737c5a64ef3f40ad5ae433405599eba2e73beccd51d2e62641d900dfa653ea |
|
MD5 | 3787447888717480241b7f14b6230623 |
|
BLAKE2b-256 | 726904f4a1006177211ed64d8143b8fbdc44134f59657dcd972dcbdd07861645 |
Close
Hashes for coredis-3.5.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 902690a2ce7bd60896fac6be2af6b71637e117cd40b39d1e81fb52d1979adfdd |
|
MD5 | 67d6a81450944dccf12c1cc6599492c5 |
|
BLAKE2b-256 | 0f6f7eb2fd7dea3304c055630525ae765f01b7d09b4dda9552b4d16ba4523023 |
Close
Hashes for coredis-3.5.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6301752eb8d3e620cbc60c969bcbe588e4aa3953d51b8cd41d9a06af08b7c5c |
|
MD5 | 357e58022c8ca555c3d5be0e5027be6c |
|
BLAKE2b-256 | 344a5fb3b7de72cb8f705b949fc2b8279bb089f65232885f55856fa1e77fa48c |
Close
Hashes for coredis-3.5.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8acc1632232388ff4e5d20993d74b4234978bb6e154a91042da95fda9425d443 |
|
MD5 | bc594a411000e5000ce193c6d7b5f83a |
|
BLAKE2b-256 | ef44a2a34b0ae9d0c66e03ee9cbc391db81e5c3f6ee2fe92481562ac3fd43296 |
Close
Hashes for coredis-3.5.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f321326e708cb37067b3ac375521777881118976bb3a51cf7d08444de871b98 |
|
MD5 | d0f4f15bf1d45602acc0b143e22d36fc |
|
BLAKE2b-256 | eb6b76d1048b2839d53c80526ea8850bc8ad2d500b7403bbd9b2965458e5a61f |
Close
Hashes for coredis-3.5.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff47e6886e9564a0857a8b8c536d462d34f26ef315b85e92d704dfcaf4f31999 |
|
MD5 | 57f0b2e94364ba7137d534fdf6dfe18c |
|
BLAKE2b-256 | 38540dccd0c802e06605d300167b310fa5f49b9f4b7d2ffa202035aa9d886213 |
Close
Hashes for coredis-3.5.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3558cbbbe7c6c868e3e211f7c5b7f121b948d94a4aa622cb793acacc969d6a0 |
|
MD5 | 65fd8aa651360c99a4b99e5b0cc7adfe |
|
BLAKE2b-256 | cd5d45be615e7d03e790c4e8556532af34079803f27a5d2bd6db57a4e45ef40f |
Close
Hashes for coredis-3.5.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec04dbd9f710aa92195eb54605f3fc88fbf4ccff1802fd4ce1efcf243820b16f |
|
MD5 | 0104ea7c8448a9e6e45141da0ebd7ec5 |
|
BLAKE2b-256 | ea8caf174fd1a53da799b81a3b0a1f76cf0432209c52f74a67d59c2c5175bd18 |
Close
Hashes for coredis-3.5.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 928cd36d7875e258939982e5d3deb7abf35ff9a7a47ff5cb9936e1819e891c98 |
|
MD5 | 7edae5d902a83b5e807fafb35a5c807a |
|
BLAKE2b-256 | 1d8f5fda38daec542442731d218824262cc9d568103a36e4186864832999009e |