openframe-adapters-db-redis
Redis key-value adapter for the OpenFrame Microservice Development Suite.
Part of the openframe-adapters monorepo.
What it provides
| Symbol | Purpose |
|---|---|
RedisSettings |
Pydantic-settings subclass — reads all config from env vars |
RedisRepository[T] |
Generic async repository — BaseRepository[T] + HealthCheck |
get_redis_client() |
Async factory — creates and caches the redis.asyncio.Redis client |
RedisPlugin |
BasePort (Identity + Lifecycle) — registered via PluginRegistry/ApplicationBootstrap |
Installation
# Via meta-package (recommended)
pip install "openframe-adapters[redis]"
# Or directly
pip install openframe-adapters-db-redis
Quick start
from openframe.adapters.db.redis import RedisSettings, RedisRepository
settings = RedisSettings(redis_url="redis://localhost:6379/0")
repo = RedisRepository(settings)
# Store and retrieve
await repo.create({"id": "user-1", "name": "Alice"})
user = await repo.get("user-1") # {"id": "user-1", "name": "Alice"}
await repo.update({"id": "user-1", "name": "Alice B."})
await repo.delete("user-1") # True
Configuration
| Env var | Default | Description |
|---|---|---|
REDIS_URL |
required | redis://[:password@]host[:port][/db] or rediss:// for TLS |
REDIS_MAX_CONNECTIONS |
10 |
Max connections in pool |
REDIS_SOCKET_TIMEOUT |
5.0 |
Socket read/write timeout (seconds) |
REDIS_SOCKET_CONNECT_TIMEOUT |
5.0 |
Connection timeout (seconds) |
REDIS_KEY_PREFIX |
"openframe" |
Key namespace — keys stored as {prefix}:{id} |
REDIS_DEFAULT_TTL |
0 |
TTL in seconds; 0 = no expiry |
Typed domain objects
from dataclasses import dataclass
from openframe.adapters.db.redis import RedisRepository, RedisSettings
@dataclass
class Session:
id: str
user_id: str
token: str
class SessionRepository(RedisRepository[Session]):
def _dict_to_entity(self, data: dict) -> Session:
return Session(**data)
def _entity_to_dict(self, entity: Session) -> dict:
return {"id": entity.id, "user_id": entity.user_id, "token": entity.token}
Plugin lifecycle (optional)
from openframe.core.runtime import ApplicationBootstrap
from openframe.core.ports import Capability
from openframe.adapters.db.redis import RedisPlugin, RedisSettings
async with ApplicationBootstrap.compose(RedisPlugin(RedisSettings())) as app:
repo = app.get(Capability.CACHE)
ApplicationBootstrap.compose() is the recommended entry point for wiring
one or a few ports — no config=/init_timeout= boilerplate needed. Reach
for a configure() subclass only when you need per-port config/timeouts or
conditional registration order, and for app.registry (the underlying
PluginRegistry) only for what neither tier covers.
License
MIT — © Furious Meteors Engineering
Metadata
Release files for openframe-adapters-db-redis 2.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openframe_adapters_db_redis-2.0.6.tar.gz | 16.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openframe_adapters_db_redis-2.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.8 kB
Release files / openframe_adapters_db_redis-2.0.6.tar.gz
| Download URL | openframe_adapters_db_redis-2.0.6.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
80c5eaf8fb3b4ed040375472268d8feff08ce7d1f195fd261d271c148e00c47c
|
|
BLAKE2b-256 checksum How to use checksums |
4253a3168e053bbb51f048f2e05f893c79bdbfb9cf599898147e1872a49c35d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / openframe_adapters_db_redis-2.0.6-py3-none-any.whl
| Download URL | openframe_adapters_db_redis-2.0.6-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed96288f93a24c35857909d3baafcbab0a4e74600e3509f29cb2134b31b6bc07
|
|
BLAKE2b-256 checksum How to use checksums |
7007986b6d086abedca25bfc4200852875343918486f964f6be9a9cd6bbb39c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|