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 OpenFramePlugin — structured lifecycle via PluginRegistry

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.plugins import PluginRegistry
from openframe.adapters.db.redis import RedisPlugin, RedisSettings

registry = PluginRegistry()
registry.register(RedisPlugin(RedisSettings()))
await registry.initialize_all()

plugin = registry.get("cache")          # capability = "cache"
repo = plugin.get_repository()

License

MIT — © Furious Meteors Engineering

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openframe_adapters_db_redis-1.2.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openframe_adapters_db_redis-1.2.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file openframe_adapters_db_redis-1.2.0.tar.gz.

File metadata

File hashes

Hashes for openframe_adapters_db_redis-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e5f85d921084c8b30f90edc50389d607a697f0e67322d8cf067e86e1a00a974e
MD5 a401e989328764a971eca646e6112176
BLAKE2b-256 5a5c001a6b1743a5181e6cee3da13515e8a573bb7e49922334c132ce5c3e5446

See more details on using hashes here.

File details

Details for the file openframe_adapters_db_redis-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openframe_adapters_db_redis-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31ef083adf625db03f5d9220fa315176ab15cb9de61ca5092abc38fcc49bf14c
MD5 61a268c0aafeb6e5e968dc618457a128
BLAKE2b-256 86b1166bc8231a15b47ad78186db28c8371ff57d413eb9844c57f68d588d1549

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

This release

1.2.0 This release

2 files

1.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page