ulfblk-redis
Redis async utilities: cache, streams with consumer groups, and health checks.
Features
- RedisManager - Connection lifecycle, async context manager, tenant-aware key prefixing
- RedisCache - Key-value cache with TTL, JSON serialization,
@cacheddecorator - StreamProducer / StreamConsumer - Redis Streams with consumer groups, auto-claim pending messages
- Health check - Compatible with
ulfblk-coreHealthResponse.checks
Installation
uv add ulfblk-redis
Quick Start
Cache
from ulfblk_redis.client import RedisManager, RedisSettings
from ulfblk_redis.cache import RedisCache, cached
settings = RedisSettings(url="redis://localhost:6379/0", key_prefix="myapp")
async with RedisManager(settings) as manager:
cache = RedisCache(manager, default_ttl=300)
await cache.set("user:1", {"name": "Alice"})
user = await cache.get("user:1") # {"name": "Alice"}
# Decorator
@cached(cache, ttl=60)
async def get_user(user_id: str) -> dict:
return await db.fetch_user(user_id)
Streams
from ulfblk_redis.client import RedisManager
from ulfblk_redis.streams import StreamProducer, StreamConsumer
async with RedisManager() as manager:
producer = StreamProducer(manager, stream="events")
await producer.publish({"action": "signup", "user": "alice"})
consumer = StreamConsumer(
manager, stream="events", group="workers", consumer_name="w1"
)
await consumer.ensure_group()
async for msg in consumer.listen():
print(msg.data)
await consumer.ack(msg.message_id)
Multitenant
# Automatic tenant prefixing (soft dependency on ulfblk-multitenant)
settings = RedisSettings(key_prefix="app", tenant_aware=True)
manager = RedisManager(settings)
# With ulfblk_multitenant context active (tenant_id="t1"):
# manager.make_key("session:abc") -> "app:t1:session:abc"
# Or explicit:
# manager.make_key("session:abc", tenant_id="t1") -> "app:t1:session:abc"
Health Check
from ulfblk_redis.health import redis_health_check
checks = await redis_health_check(manager)
# {"redis": True}
Dependencies
ulfblk-core- Logging, health response schemasredis[hiredis]>=5.0- Async Redis client
Development
uv sync --all-packages --all-extras
uv run pytest packages/python/ulfblk-redis -v
Metadata
Release files for ulfblk-redis 0.1.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 | |
|---|---|---|---|
| ulfblk_redis-0.1.0.tar.gz | 9.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ulfblk_redis-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.9 kB
Release files / ulfblk_redis-0.1.0.tar.gz
| Download URL | ulfblk_redis-0.1.0.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9d7361b2779683bd3d2e258ad4441f27d86747fb80164c08843cb3d54d25b77
|
|
BLAKE2b-256 checksum How to use checksums |
e88cd26483d82d514e13d43df47f8cbcaf4d279f9e6377139034c45d573ff0ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / ulfblk_redis-0.1.0-py3-none-any.whl
| Download URL | ulfblk_redis-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5ec9cf7d8982e9bea06988867b05b0dec74e327f79bcc3851e43821125faeed
|
|
BLAKE2b-256 checksum How to use checksums |
d2f5522ceb6a3b62721b88141e72df90339bc7eda2ad82e612a8a8cb89ef4ce0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|