reddish - an redis client for sockets and trio with minimal api
Features
- both sync and async API
- sync api using the standard library
socketmodule (TPC, TPC+TLS, Unix domain sockets) async/awaitusingtrio's stream primitives (TCP, TCP+TLS, Unix domain sockets)- minimal api so you don't have to relearn how to write redis commands
- supports all redis commands including modules except
SUBSCRIBE,PSUBSCRIBEandMONITOR1 - parses responses back into python types if you like (powered by pydantic)
- works with every redis version and supports both
RESP2andRESP3protocols
Installation
pip install reddish # install just with support for socket
pip install reddish[trio] # install with support for trio
Minimal Example - sync version
import socket
from reddish.socket import Redis, Command
redis = Redis(socket.create_connection(('localhost', 6379)))
assert b'PONG' == redis.execute(Command('PING'))
Minimal Example - async version
import trio
from reddish.trio import Redis, Command
redis = Redis(await trio.open_tcp_stream('localhost', 6379))
assert b'PONG' == await redis.execute(Command('PING'))
Usage
Command with a fixed number of arguments
# simple command without any arguments
Command('PING')
# commands with positional arguments
Command('ECHO {}', 'hello world')
# commands with keyword arguments
Command('SET {key} {value}', key='foo', value=42)
Command with response parsing
# return response unchanged from redis
assert b'42' == await redis.execute(Command('ECHO {}', 42))
# parse response as type
assert 42 == await redis.execute(Command('ECHO {}', 42).into(int))
# use any type that works with pydantic
from pydantic import Json
import json
data = json.dumps({'alice': 30, 'bob': 42})
response == await redis.execute(Command('ECHO {}', data).into(Json))
assert response == json.loads(data)
Command with variadic arguments
from reddish.trio import Args
# inlining arguments
Command('DEL {keys}', keys=Args(['foo', 'bar'])) # DEL foo bar
# inlining pairwise arguments
data = {'name': 'bob', 'age': 42}
Command('XADD foo * {fields}', fields=Args.from_dict(data)) # XADD foo * name bob age 42
Pipelining commands
foo, bar = await redis.execute_many(Command('GET', 'foo'), Command('GET', 'bar'))
Transactions
from reddish.trio import MultiExec
tx = MultiExec(
Command('ECHO {}', 'foo'),
Command('ECHO {}', 'bar')
)
foo, bar = await redis.execute(tx)
# pipelining together with transactions
[foo, bar], baz = await redis.execute_many(tx, Command('ECHO {}', 'baz'))
-
Commands like
SUBSCRIBEorMONITORtake over the redis connection for listeting to new events barring regular commands from being issued over the connection. ↩
Metadata
Release files for reddish 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| reddish-0.4.0.tar.gz | 9.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| reddish-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.9 kB
Release files / reddish-0.4.0.tar.gz
| Download URL | reddish-0.4.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ad199cd869e97cc6d0440dab56d1b7f1f4c012de0b884aea6845e05259d9a81
|
|
BLAKE2b-256 checksum How to use checksums |
8f7f1c9e895c5d3feb265c2f7ecec9c6dfeb91f30e7edb4c3ba1b384c34ecef8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.9.9 Linux/5.11.0-1021-azure
|
Release files / reddish-0.4.0-py3-none-any.whl
| Download URL | reddish-0.4.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3926ecb78d63fbdb5b1d58704f59d5fb4a30bf03ea64e71ffc3764c5ead87cfa
|
|
BLAKE2b-256 checksum How to use checksums |
08f9e93b64f98127a9f8a941711bde3999b2305b0ab4e6e363e123830f7a0dac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.9.9 Linux/5.11.0-1021-azure
|
Security for reddish 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.