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-2.0.3.tar.gz (80.7 kB view details)

Uploaded Source

Built Distributions

yaaredis-2.0.3-cp38-cp38-manylinux_2_28_x86_64.whl (108.0 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

yaaredis-2.0.3-cp37-cp37m-manylinux_2_28_x86_64.whl (109.1 kB view details)

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

yaaredis-2.0.3-cp37-cp37m-macosx_10_15_x86_64.whl (111.6 kB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

yaaredis-2.0.3-cp36-cp36m-manylinux_2_28_x86_64.whl (108.1 kB view details)

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

yaaredis-2.0.3-cp35-cp35m-manylinux_2_28_x86_64.whl (107.9 kB view details)

Uploaded CPython 3.5m manylinux: glibc 2.28+ x86-64

File details

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

File metadata

  • Download URL: yaaredis-2.0.3.tar.gz
  • Upload date:
  • Size: 80.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.8.11 Linux/4.15.0-1103-aws

File hashes

Hashes for yaaredis-2.0.3.tar.gz
Algorithm Hash digest
SHA256 266e87d75c5ea51a01b6b58a6eff1cd969191a92ea79afe7497c6c14592ee044
MD5 a7b091298527bc0c9657342211dcc4da
BLAKE2b-256 37a405fc606ac7e41bf38a9fcce4230fce5c7f491b61eb84ab2f449e427cade2

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.3-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.3-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0dd59bea078ad7794cbe7ed29a5845b2c3ef13afe1f6a3b339ed9a1dc5303061
MD5 431b128c21ca0322d00c91def5225f21
BLAKE2b-256 5d46aae1fd32485c75448d1b6214da1c910e71a22cc19349aa46fa3463e78deb

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.3-cp37-cp37m-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.3-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04a17c98549bd4e7a8358ea9a7cb4fc654376207506a1dec38c830a97f408105
MD5 38f95c450df1b47e6a0a14867fd53bc2
BLAKE2b-256 ecfe52cd49a427c061048951d16b09b7a2fa793f84a9787aaae2372cd41b4e5e

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.3-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.3-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 34a013bdb24a3e7c3872f0fc9d630de4c724e7e82e5aa29fa5c45b59e0ff86a7
MD5 ce0a64a4e87977bb2cb70b38d468f200
BLAKE2b-256 3b0d38d283a1966caa1a881b24916d0873b9b9046bab0ffd52b1d2ecb01f3b42

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.3-cp36-cp36m-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.3-cp36-cp36m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3427fb165829020c5b26711412ff8f3801096e081be4a2b0e9fe3efdd5f29e2b
MD5 e9775662bf2f7664d91578d0e30773b2
BLAKE2b-256 0116c07e31d5ca48cd99fec6f6bac89d2eff2a4152d7ac9da34e5c3f7893d3e1

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.3-cp35-cp35m-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.3-cp35-cp35m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9b5ab91c7f15f38359fd8b68b262178d509b96d860ec6738f7996e71577cd8b9
MD5 66b49e5eb23acd8460972759a41464f1
BLAKE2b-256 4f802dd14222bf7d4203e76bc9df1fff17401bc40c527bcf41b4d0c78749a6a7

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