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.3.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-2.0.3-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for openframe_adapters_db_redis-2.0.3.tar.gz
Algorithm Hash digest
SHA256 475d5dfd7e20f73f4c4e6c92358dcf353fa1b72309bcb4404db15dd4edccf649
MD5 283cf111aff2c9a1d0a516e86972b35b
BLAKE2b-256 bdf10fb30df07e237674c303de6452e649fd194aed526430d6caf156e0c65b4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for openframe_adapters_db_redis-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d8e85f31f65a344987737ffbd5eb768604e13cced983463e693df5e4b786fc06
MD5 adbd1d296e44e1d207f47ebc3a889714
BLAKE2b-256 6d4df3ebffd63613554120fd2aee2f087a34bbb4d9c75003bec4d37e4df1074c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 files

2.0.2

2 files

2.0.1

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