Skip to main content

Python async client for Redis key-value store

Project description

CircleCI Test Status Latest PyPI Release Compatible Python Versions

yaaredis (Yet Another Async Redis (client)) is a fork of aredis, which itself was ported from redis-py. yaaredis provides an efficient and user-friendly async redis client with support for Redis Server, Cluster, and Sentinels.

To get more information please read the full documentation managed by the upstream aredis repo. We are working on hosting our own as the projects diverge – stay tuned!

Installation

yaaredis requires a running Redis server. To install yaaredis, simply:

python3 -m pip install yaaredis

or from source:

python3 -m pip install .

Note that yaaredis also supports using hiredis as a drop-in performance improvements. You can either install hiredis separately or make use of the PyPI extra to make use of this functionality:

python3 -m pip install yaaredis[hiredis]

Getting started

We have various examples in this repo which you may find useful. A few more specific cases are listed below.

Single Node Client

import asyncio
from yaaredis import StrictRedis

async def example():
    client = StrictRedis(host='127.0.0.1', port=6379, db=0)
    await client.flushdb()
    await client.set('foo', 1)
    assert await client.exists('foo') is True
    await client.incr('foo', 100)

    assert int(await client.get('foo')) == 101
    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 yaaredis import StrictRedisCluster

async def example():
    client = StrictRedisCluster(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}]}

Benchmark

Please run test scripts in the benchmarks directory to confirm the benchmarks. For a benchmark in the original yaaredis author’s environment please see: benchmark.

Contributing

Developer? See our guide on how you can contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaaredis-3.0.0.tar.gz (80.4 kB view details)

Uploaded Source

Built Distributions

yaaredis-3.0.0-cp310-cp310-manylinux_2_31_x86_64.whl (102.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.31+ x86-64

yaaredis-3.0.0-cp310-cp310-macosx_12_0_x86_64.whl (96.4 kB view details)

Uploaded CPython 3.10 macOS 12.0+ x86-64

yaaredis-3.0.0-cp39-cp39-manylinux_2_31_x86_64.whl (102.1 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.31+ x86-64

yaaredis-3.0.0-cp39-cp39-macosx_12_0_x86_64.whl (96.4 kB view details)

Uploaded CPython 3.9 macOS 12.0+ x86-64

yaaredis-3.0.0-cp38-cp38-manylinux_2_31_x86_64.whl (102.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.31+ x86-64

yaaredis-3.0.0-cp38-cp38-macosx_12_0_x86_64.whl (96.4 kB view details)

Uploaded CPython 3.8 macOS 12.0+ x86-64

yaaredis-3.0.0-cp37-cp37m-manylinux_2_31_x86_64.whl (102.7 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.31+ x86-64

yaaredis-3.0.0-cp37-cp37m-macosx_12_0_x86_64.whl (96.4 kB view details)

Uploaded CPython 3.7m macOS 12.0+ x86-64

yaaredis-3.0.0-cp36-cp36m-manylinux_2_31_x86_64.whl (102.7 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.31+ x86-64

File details

Details for the file yaaredis-3.0.0.tar.gz.

File metadata

  • Download URL: yaaredis-3.0.0.tar.gz
  • Upload date:
  • Size: 80.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Linux/5.11.0-1022-aws

File hashes

Hashes for yaaredis-3.0.0.tar.gz
Algorithm Hash digest
SHA256 d459912a84c035e6173cfb595b7fe52bbaecba3198c8b19f051112c42ec4b4b9
MD5 6b45d0656852e4f9bc0bf759e4d54ec4
BLAKE2b-256 9d8e980cb1fd05c2c141e370f39fef4fcc7a5890df026a838d0a4aa85524cd45

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp310-cp310-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 bc1d640693749c57fcd97a826c5e45dc14a88a15d24503c0c445f5bf34867d54
MD5 ea7cd1b555cbcbed92d7a8a0a9cef9e5
BLAKE2b-256 7ef74af87df2659feb8622be67ccd544e5734bf60a65738db73e66c737daab32

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp310-cp310-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 7a972b5ed6255903458895712ac7df16df6bcdd1398333d568743f8de1c18126
MD5 754571e0fdea3a30ce02b30be78c3dbd
BLAKE2b-256 648a449a2c030fbb2462e75e288ce3f7ca57310264cd03a5ede6bb13ebbe8563

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp39-cp39-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 b487511ab5875942fd61506a31d616eb2fb9931e2bb5dd6ef98984d660abe151
MD5 d5d1f2d560b1901c94fef59e0e760cd7
BLAKE2b-256 4d1aae5db80cd75eaf745267521f1f0dd1d3a9e9009a7a99c2170109306cdb1b

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp39-cp39-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 bb656e1b8c16264297bb4a84c999bcdc750c98806e6af8225d1dde2314a53230
MD5 644d10a37edf15d7163144ecfc6991e9
BLAKE2b-256 c858ea700c50d19369957ae6c3282532d316c026e2662c3b6c68476e29c3c690

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp38-cp38-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp38-cp38-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 224f716cbf09bf16abe0d8c116bac3416ad6a9753726d426430ccc67d6757528
MD5 7b6be51517ce4a46fa3aeda8d0387f1a
BLAKE2b-256 105ce73afc99e9069ab9f6410495bfbca9a6f534852659323e7b6667781f2de8

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp38-cp38-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 935263de853f3d18f8a3b6dc3f4b8ca8c78107c2e4bd25712a2143e4831a2cc3
MD5 4fb318cdf2b5e05f4e925d34932a1ad1
BLAKE2b-256 384ba53b04ab0d49643863e70a3fdfc450c13d695c1102b46038adc22648a8c0

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp37-cp37m-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp37-cp37m-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 b612c4db5d2dc57b210a16f4e593d6650bd321e929fbbf1650c4aa6cc602aa0a
MD5 293b7a27903d4b2f5ac1902672f4c731
BLAKE2b-256 dc54410acdcb576d6153e35833260478bf7ada18b66a18de9974c9273fc0aea2

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp37-cp37m-macosx_12_0_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp37-cp37m-macosx_12_0_x86_64.whl
Algorithm Hash digest
SHA256 a77f33b99c1581ea8cfd72115f3a03698a3acc414eeec0c14390655bf02bf7b5
MD5 eb45b882f97a1f71393f2fe3ee12b41d
BLAKE2b-256 fde8eeca134675efad84756dc9237459dcd8c76bfc19566ae38761e4cfa41a52

See more details on using hashes here.

File details

Details for the file yaaredis-3.0.0-cp36-cp36m-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-3.0.0-cp36-cp36m-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 988236d9cb80bc590d5e42b1305bc53e8a8eeacee35f752222e9968df4cefcee
MD5 1af758f7b723c3eb518b3d5fef620b65
BLAKE2b-256 da53f18be0b660f572de37af3b642072c5674cb94c91be723a773fbea591a1aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page