Skip to main content

Python wrapper for redis-rs

Project description

https://img.shields.io/badge/License-MIT-blue.svg https://img.shields.io/pypi/v/redis-rs.svg Python versions Documentation Status https://github.com/aamalev/redis-rs-py/workflows/Tests/badge.svg https://img.shields.io/pypi/dm/redis-rs.svg

https://img.shields.io/badge/Rustc-1.73.0-blue?logo=rust https://img.shields.io/badge/cargo-clippy-blue?logo=rust https://img.shields.io/badge/PyO3-maturin-blue.svg https://img.shields.io/badge/PyO3-asyncio-blue.svg Linter: ruff Code style: ruff Code style: Mypy Hatch project
Python wrapper for:
redis_cluster_async,
bb8-redis,
bb8-redis-cluster,
deadpool-redis-cluster,

Features

  • Async client for single and cluster

  • Support typing

  • Encoding values from str, int, float

  • Decoding values to str, int, float, list, dict

Install

pip install redis-rs

Using

import asyncio
import redis_rs


async def main():
    async with redis_rs.create_client(
        "redis://redis-node001",
        "redis://redis-node002",
        max_size=1,
        cluster=True,
    ) as x:
        info = await x.execute("INFO", "SERVER", encoding="info")
        print(info["redis_version"])

        # parse value as json
        print(await x.get("foo", encoding="json"))

        print(await x.execute(b"HSET", "fooh", "a", b"asdfg"))
        print(await x.fetch_int("HSET", "fooh", "b", 11234567890))
        print(await x.fetch_int("HGET", "fooh", "b"))
        print(await x.fetch_str("HGET", "fooh", "a"))
        print(await x.fetch_dict("HGETALL", "fooh", encoding="utf-8"))
        print(await x.hgetall("fooh", encoding="utf-8"))
        print(await x.execute("CLUSTER", "NODES"))
        print(await x.fetch_bytes("GET", "foo"))
        print(await x.fetch_int("GET", "foo"))
        print(await x.execute("HGETALL", "fooh"))
        print(await x.execute("ZADD", "fooz", 1.5678, "b"))
        print(await x.fetch_scores("ZRANGE", "fooz", 0, -1, "WITHSCORES"))
        print(x.status())

        stream = "redis-rs"
        print("x.xadd", await x.xadd(stream, "*", {"a": "1234", "d": 4567}))
        print("x.xadd", await x.xadd(stream, items={"a": "1234", "d": 4567}))
        print("x.xadd", await x.xadd(stream, {"a": "1234", "d": 4567}))
        print("x.xadd", await x.xadd(stream, "*", "a", "1234", "d", 4567))
        print("x.xadd", await x.xadd(stream, "a", "1234", "d", 4567))
        print("xadd", await x.fetch_str("XADD", stream, "*", "a", "1234", "d", 4567))
        print("xread", await x.execute("XREAD", "STREAMS", stream, 0))
        print("xread", await x.fetch_dict("XREAD", "STREAMS", stream, 0, encoding="int"))
        print("x.xread", await x.xread({stream: 0}, encoding="int"))
        print("x.xread", await x.xread(stream, id=0, encoding="int"))
        print("x.xread", await x.xread(stream, stream))


asyncio.run(main())

Development

cargo fmt
cargo clippy
maturin develop

or use hatch envs:

hatch run fmt
hatch run check
hatch run build

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

redis_rs-0.11.1.tar.gz (33.9 kB view hashes)

Uploaded Source

Built Distributions

redis_rs-0.11.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

redis_rs-0.11.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

redis_rs-0.11.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

redis_rs-0.11.1-cp312-none-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

redis_rs-0.11.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

redis_rs-0.11.1-cp311-none-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

redis_rs-0.11.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

redis_rs-0.11.1-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (4.5 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

redis_rs-0.11.1-cp310-none-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

redis_rs-0.11.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

redis_rs-0.11.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (4.5 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

redis_rs-0.11.1-cp39-none-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

redis_rs-0.11.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

redis_rs-0.11.1-cp38-none-win_amd64.whl (1.9 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

redis_rs-0.11.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

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