Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4688dd4181 | ||
|
|
a0e9fc28d6 |
@@ -14,19 +14,19 @@ datastore trio (`redis` / `psql` / `mysql`), a sibling of the `mongo` lib.
|
||||
`requirements.txt`:
|
||||
|
||||
```
|
||||
redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.1
|
||||
redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.3
|
||||
```
|
||||
|
||||
Direct:
|
||||
|
||||
```bash
|
||||
pip install "redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.1"
|
||||
pip install "redis_store @ git+ssh://git@git.rethinkstudios.io/rethink-public/redis.git@v0.1.3"
|
||||
```
|
||||
|
||||
Pulls `redis>=5` (redis-py, which ships the asyncio client — **not** the dead standalone
|
||||
`aioredis`).
|
||||
|
||||
Drop the `@v0.1.1` suffix from the line above to install the latest unpinned.
|
||||
Drop the `@v0.1.3` suffix from the line above to install the latest unpinned.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -62,6 +62,15 @@ One client/pool per process — build it once, attach it to your app (`app.kv =
|
||||
`None` for an absent key). Pass `decode_responses=False` at construction for raw `bytes`.
|
||||
Counters and counts (`incr`/`decr`/`exists`/`ttl`) always return `int` regardless.
|
||||
|
||||
Pool sizing/timeout are `max_connections=` and `pool_timeout=` (how long a caller waits for
|
||||
a free connection when the pool is saturated). Pass the driver's own `timeout=` in
|
||||
`pool_kwargs` and construction raises a clear `ValueError` — use `pool_timeout=`.
|
||||
|
||||
`ssl=True` maps to `connection_class=redis.asyncio.SSLConnection`, so TLS works via the
|
||||
documented `pool_kwargs` path (the default connection class has no `ssl` parameter and
|
||||
would otherwise defer a `TypeError` to `connect()`). Pass ssl-prefixed kwargs alongside
|
||||
it (`ssl_ca_certs`, `ssl_certfile`, ...) to configure the handshake.
|
||||
|
||||
## Error contract — fail loud
|
||||
|
||||
Unlike the `mongo` lib (which log-and-swallows, returning a safe default), **this lib
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "redis_store"
|
||||
version = "0.1.1"
|
||||
version = "0.1.3"
|
||||
description = "async redis wrapper over redis-py asyncio with a raw escape hatch, fail-loud and config-free"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
|
||||
@@ -34,6 +34,9 @@ notes:
|
||||
- import is `redis_store`; the repo/distribution is `redis` (the driver owns the
|
||||
`redis` import name, so the package can't also be `redis`)
|
||||
- pub/sub and pipeline helpers are intentionally not wrapped yet — use `.client`
|
||||
- ssl=True maps to connection_class=redis.asyncio.SSLConnection so TLS actually
|
||||
works via the documented pool_kwargs path; pass ssl-prefixed kwargs alongside it
|
||||
(ssl_ca_certs, ssl_certfile, ...) to configure the handshake
|
||||
"""
|
||||
|
||||
import logging
|
||||
@@ -71,7 +74,25 @@ class RedisDB:
|
||||
max_connections, callers WAIT up to pool_timeout seconds for a free connection
|
||||
(matching motor/mongo's blocking pool) rather than the plain pool's behavior of
|
||||
raising MaxConnectionsError immediately. pool_timeout=None waits forever.
|
||||
|
||||
`timeout` is the pool's own kwarg (set from pool_timeout here), so passing it in
|
||||
pool_kwargs would collide — reject it with a clear pointer rather than let the
|
||||
driver raise a cryptic "multiple values for 'timeout'".
|
||||
|
||||
`ssl=True` is mapped to `connection_class=redis.asyncio.SSLConnection` — the
|
||||
default async Connection class has no `ssl` parameter, so passing it straight
|
||||
through pool_kwargs would defer the failure to connect() as a raw TypeError.
|
||||
pass ssl-prefixed kwargs (ssl_ca_certs, ssl_certfile, ...) alongside ssl=True to
|
||||
configure the TLS connection; an explicit connection_class in pool_kwargs is
|
||||
left untouched.
|
||||
"""
|
||||
if "timeout" in pool_kwargs:
|
||||
raise ValueError(
|
||||
"redis_store: pass the pool wait timeout as pool_timeout=, not timeout= "
|
||||
"(timeout is filled from pool_timeout)"
|
||||
)
|
||||
if pool_kwargs.pop("ssl", False):
|
||||
pool_kwargs.setdefault("connection_class", redis.SSLConnection)
|
||||
self._pool = redis.BlockingConnectionPool(
|
||||
host=host,
|
||||
port=port,
|
||||
|
||||
Reference in New Issue
Block a user