Skip to main content

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.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openframe-adapters-db-redis 2.0.5
File Size Uploaded
openframe_adapters_db_redis-2.0.5.tar.gz 16.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openframe-adapters-db-redis 2.0.5
File Interpreter ABI Platform
openframe_adapters_db_redis-2.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / openframe_adapters_db_redis-2.0.5.tar.gz

Download URL openframe_adapters_db_redis-2.0.5.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2cf52adad4a2d0751c203618b77e892d94446fde1f0d6d68d00c6be788ee88c7
BLAKE2b-256 checksum
How to use checksums
492dff1a4a158e6e1a4712779a6f705d857eafd0fd92362e30105b7afdcdf64e
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.5-py3-none-any.whl

Download URL openframe_adapters_db_redis-2.0.5-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7abc0c07922b7543fb97615da1f8d7c14145c5edf1796303e4bd5670595b299f
BLAKE2b-256 checksum
How to use checksums
5c8be525d21819240c6cf27eed86b7e97dc65c7812df3b160e44389fd8a60668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

2.0.6

2 release files

This release

2.0.5 This release

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page