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

Uploaded Source

Built Distributions

yaaredis-2.0.4-cp39-cp39-macosx_10_15_x86_64.whl (96.8 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

yaaredis-2.0.4-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.4-cp38-cp38-macosx_10_15_x86_64.whl (96.8 kB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

yaaredis-2.0.4-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.4-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.4-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.4-cp36-cp36m-macosx_10_15_x86_64.whl (96.8 kB view details)

Uploaded CPython 3.6m macOS 10.15+ x86-64

yaaredis-2.0.4-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.4.tar.gz.

File metadata

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

File hashes

Hashes for yaaredis-2.0.4.tar.gz
Algorithm Hash digest
SHA256 30c5ad1834c92d9391fa56206f6bd29278f1e158653ed4b19acb67b4dc3d285f
MD5 7091b5957b7c3d331f12df10771f0c2a
BLAKE2b-256 a5392ea350b82e004d1acf88132ab03c25e2248425a632b8b4dbfa3b541b4280

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.4-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 438c4a4c4b082bccc36817a6ac0752c3d711bf5c66af74c4c9a70622a50bb05e
MD5 363cf9923b812b474484310c49e7ce86
BLAKE2b-256 010650f931fb4fc8fe13c4ece3c1311602ec955ebb10f45fcb0f1b6569165f46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f251de75d32465f1a3017dca2d64e7396f5ccfb4b52ef087c8aea4df03600693
MD5 1a4fb57654dbae062736192081a65bd1
BLAKE2b-256 b8399e75394c80b18c87bec774d10e03a07f60279b28cc4af723aacca01834fd

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.4-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8bf94a9ee09211d51795cdccd0f1321ee1fc9ac260c2e8db10f02dbb7610ab92
MD5 34d21bbe4a845e2d7e8e91877581f419
BLAKE2b-256 c562d73d3fbf70f4ade93242e651071412caeae08a01ad915c8d647d90a01845

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0abb9d79adf721dcf817e903bcb5bdc7e3816ac9a840b7d8fb79989fb847663b
MD5 e728592a883a8a80332c5c9caadd9288
BLAKE2b-256 59638065f95a7696b563e4ac5097d0f632d376ff26aac43f727eb224b145b93f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 20367c93f33be0a4c4672b1e73118d7221d649567ec1236991a4945afe533c8f
MD5 5cbd83c414b7dcb7c4959d9ae5996602
BLAKE2b-256 4b8c47e61483e71e0317562c9c129818c93547beba8b9d7aff92cacac6f92c09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp36-cp36m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a8e5751c3e473e59001cc5ca51e418a07c7549d684c176721711b22af1515124
MD5 d77406d7318d94fe146be4ccfec31698
BLAKE2b-256 dc9864762f35a2639b1453ab7dedb717e6b0c1672c7c61642e295b0c028a012b

See more details on using hashes here.

File details

Details for the file yaaredis-2.0.4-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6f98f328075634f7b6d3e908767a1edd798ed70b5534deff171a205f47c8233e
MD5 6494607989992466519d08e398f7084c
BLAKE2b-256 d9404be1a08ff6c33d14442c64ccbcaae1c786d1201a1823373798ea0d9f586a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yaaredis-2.0.4-cp35-cp35m-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7286c8d32fa7ce4c53b7a0c3a368374a41aa4a66ebd866f51651028d87326882
MD5 36480c4764a805f75d0ce74b00a37867
BLAKE2b-256 34b256a7f9e31acfda117973d36048329c86634295ee2ce64e621f4c19b6a52d

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