Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aamalev/redis-rs-py
Python package from redis-rs
https://github.com/aamalev/redis-rs-py
asyncio python redis rust
Last synced: 13 days ago
JSON representation
Python package from redis-rs
- Host: GitHub
- URL: https://github.com/aamalev/redis-rs-py
- Owner: aamalev
- License: mit
- Created: 2022-11-20T22:32:48.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-07T17:03:11.000Z (about 1 month ago)
- Last Synced: 2024-10-07T23:48:33.157Z (about 1 month ago)
- Topics: asyncio, python, redis, rust
- Language: Rust
- Homepage:
- Size: 139 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
redis-rs
========.. image:: https://img.shields.io/badge/License-MIT-blue.svg
:target: https://lbesson.mit-license.org/.. image:: https://img.shields.io/pypi/v/redis-rs.svg
:target: https://pypi.org/project/redis-rs.. image:: https://img.shields.io/pypi/pyversions/redis-rs.svg
:target: https://pypi.org/project/redis-rs
:alt: Python versions.. image:: https://readthedocs.org/projects/redis-rs/badge/?version=latest
:target: https://github.com/aamalev/redis-rs-py#redis-rs
:alt: Documentation Status.. image:: https://github.com/aamalev/redis-rs-py/workflows/Tests/badge.svg
:target: https://github.com/aamalev/redis-rs-py/actions?query=workflow%3ATests.. image:: https://img.shields.io/pypi/dm/redis-rs.svg
:target: https://pypi.org/project/redis-rs|
.. image:: https://img.shields.io/badge/Rustc-1.73.0-blue?logo=rust
:target: https://www.rust-lang.org/.. image:: https://img.shields.io/badge/cargo-clippy-blue?logo=rust
:target: https://doc.rust-lang.org/stable/clippy/.. image:: https://img.shields.io/badge/PyO3-maturin-blue.svg
:target: https://github.com/PyO3/maturin.. image:: https://img.shields.io/badge/PyO3-asyncio-blue.svg
:target: https://github.com/awestlake87/pyo3-asyncio.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Linter: ruff.. image:: https://img.shields.io/badge/code%20style-ruff-000000.svg
:target: https://github.com/astral-sh/ruff
:alt: Code style: ruff.. image:: https://img.shields.io/badge/types-Mypy-blue.svg
:target: https://github.com/python/mypy
:alt: Code style: Mypy.. image:: https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg
:alt: Hatch project
:target: https://github.com/pypa/hatchPython wrapper for:
| `redis-rs `_,
| `bb8 `_,
| bb8-redis,Features
--------* Async client for single and cluster
* Support typing
* Encoding values from str, int, float
* Decoding values to str, int, float, list, dictInstall
-------.. code-block:: shell
pip install redis-rs
Using
-----.. code-block:: python
import asyncio
import redis_rsasync 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
-----------.. code-block:: python
cargo fmt
cargo clippy
maturin developor use hatch envs:
.. code-block:: python
hatch run fmt
hatch run check
hatch run build