2 Commits
Author SHA1 Message Date
dsql 4688dd4181 fix: map ssl=True to connection_class=SSLConnection so TLS works via pool_kwargs (redis-4)
Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-02 17:22:30 -04:00
dsql a0e9fc28d6 fix: reject timeout= in pool_kwargs with a clear ValueError (redis-2)
a caller passing the driver-native timeout= (instead of pool_timeout=) would hit a cryptic
'multiple values for timeout' from BlockingConnectionPool. now raise a clear ValueError
pointing at pool_timeout. verified vs real redis. README note added. bump v0.1.1 -> v0.1.2

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-01 00:28:18 -04:00
3 changed files with 34 additions and 4 deletions
+12 -3
View File
@@ -14,19 +14,19 @@ datastore trio (`redis` / `psql` / `mysql`), a sibling of the `mongo` lib.
`requirements.txt`: `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: Direct:
```bash ```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 Pulls `redis>=5` (redis-py, which ships the asyncio client — **not** the dead standalone
`aioredis`). `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 ## 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`. `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. 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 ## Error contract — fail loud
Unlike the `mongo` lib (which log-and-swallows, returning a safe default), **this lib Unlike the `mongo` lib (which log-and-swallows, returning a safe default), **this lib
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project] [project]
name = "redis_store" 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" description = "async redis wrapper over redis-py asyncio with a raw escape hatch, fail-loud and config-free"
requires-python = ">=3.10" requires-python = ">=3.10"
dependencies = [ dependencies = [
+21
View File
@@ -34,6 +34,9 @@ notes:
- import is `redis_store`; the repo/distribution is `redis` (the driver owns the - import is `redis_store`; the repo/distribution is `redis` (the driver owns the
`redis` import name, so the package can't also be `redis`) `redis` import name, so the package can't also be `redis`)
- pub/sub and pipeline helpers are intentionally not wrapped yet — use `.client` - 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 import logging
@@ -71,7 +74,25 @@ class RedisDB:
max_connections, callers WAIT up to pool_timeout seconds for a free connection 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 (matching motor/mongo's blocking pool) rather than the plain pool's behavior of
raising MaxConnectionsError immediately. pool_timeout=None waits forever. 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( self._pool = redis.BlockingConnectionPool(
host=host, host=host,
port=port, port=port,