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-2.0.1.tar.gz (14.9 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-2.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openframe_adapters_db_redis-2.0.1.tar.gz
Algorithm Hash digest
SHA256 d4de5992e62178c48b1bce82074339a2b9d19e9b9b99b3c9fa729fb6a4dce4b0
MD5 ac999bb36bc1249683b9ef499079d255
BLAKE2b-256 c137acfc2a39b216184318eb7bef3e2a2792b422cad9d2ea848f9c0830f2315d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openframe_adapters_db_redis-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21e64dd77893133c5124d103ab27288ff8cc86ccc916d0915464a6698bfa8e3b
MD5 42da31379354bcdf1ead5e0b22e0484b
BLAKE2b-256 65fcf61717b7f91191c50f2a12ca3af4f015f66973f8143e8d2a47a0f983c9f8

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.3

2 files

2.0.2

2 files

This release

2.0.1 This release

2 files

2.0.0

2 files

1.2.0

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