ewoxdbredis
ewoxdbredis provides production-oriented Redis infrastructure for Python
services. It includes validated standalone and cluster clients, synchronous
and asynchronous connection lifecycles, environment-scoped repositories,
distributed caching, Redis streams, distributed locks, and durable logical
sessions.
Requirements
- Python 3.13
- Redis Server 7.4 or newer
APP_ENVfor repository and session key isolation
Redis 7.4 is required by hash-field expiration. Other features use commands available in Redis 7.4 and are tested against both standalone Redis and Redis Cluster.
Install
pip install ewoxdbredis
Asynchronous client and repository
Create one shared client during application startup, call setup() before
using it, inject it into providers and repositories, and call dispose()
during shutdown.
import asyncio
import logging
import os
from ewoxdbredis.clients.redis_instance_client import RedisInstanceClient
from ewoxdbredis.repositories.redis_expire_repository import (
RedisExpireRepository,
)
from ewoxdbredis.settings.connection_settings import ConnectionSettings
async def main() -> None:
os.environ.setdefault("APP_ENV", "development")
client = RedisInstanceClient(
ConnectionSettings(host="localhost", port=6379)
)
await client.setup()
try:
repository = RedisExpireRepository("example")
connection = client.get_connection()
await repository.set(connection, "greeting", "hello")
value: str = await repository.get(connection, "greeting")
logging.info("Greeting: %s", value)
finally:
await client.dispose()
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())
For Redis Cluster, use RedisClusterClient with the same lifecycle.
Applications create one shared IRedisClient during startup and inject it into
providers and repository implementations.
Synchronous client
DBConnection is the supported synchronous API. Entering the context creates
the configured standalone or cluster connection, validates it with PING, and
leaving the context closes it.
from ewoxdbredis.connection.db_connection import DBConnection
from ewoxdbredis.settings.connection_settings import ConnectionSettings
with DBConnection(ConnectionSettings(host="localhost")) as redis:
redis.set("example", "value")
assert redis.get("example") == "value"
Capabilities
- Standalone and Redis Cluster async clients with TLS trust configuration, mutual TLS, authentication, RESP selection, timeouts, health checks, retries, and explicit lifecycle management
- Supported synchronous standalone and cluster access through
DBConnection - Scalar, hash, set, and sorted-set repositories with environment-prefixed keys and cluster-safe scanning
- Two-level distributed caching with Redis-first writes and optional local L1
- At-least-once Redis stream consumption with retry, bounded concurrency, pending-message recovery, dead-letter inspection, replay, and shutdown
- Distributed locks with explicit ownership-loss handling and opt-in renewal and fencing tokens
- Durable logical sessions with resume-token rotation, fencing, leases, idempotent delivery IDs, browser acknowledgements, and dead-letter replay
Documentation
- Configuration and client lifecycle
- Repositories and distributed cache
- Streams and dead letters
- Distributed session management
- Operations and production guidance
- Unit and integration testing
- Release process
- Runnable examples
Development
poetry install
APP_ENV=unittest poetry run pytest -m "not integration"
poetry check --strict
poetry run ruff check --select F src tests examples scripts
poetry run pyright src/ewoxdbredis
poetry build
poetry run twine check dist/*
python scripts/verify_distribution.py dist
Run the standalone and cluster integration suites in self-contained Redis 7.4 containers:
./scripts/run_integration_tests.sh
Docker Engine or Docker Desktop with Compose v2 provisions the complete Redis test topology. See docs/testing.md for VS Code unit-test setup, integration prerequisites, cleanup, and external Redis commands. See CONTRIBUTING.md for the complete verification workflow.
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ewoxdbredis-2.0.1.tar.gz.
File metadata
- Download URL: ewoxdbredis-2.0.1.tar.gz
- Upload date:
- Size: 48.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fb0bad0b7c13bfdf3f52286f5e81e41e4085d0801306e6797371116f84cb17e
|
|
| MD5 |
09ef48de4948e3af964d25c48ac03113
|
|
| BLAKE2b-256 |
05742a0805629b7b26a3c6c7b483cda46c66ffe919726fe5e496891345dacf9a
|
File details
Details for the file ewoxdbredis-2.0.1-py3-none-any.whl.
File metadata
- Download URL: ewoxdbredis-2.0.1-py3-none-any.whl
- Upload date:
- Size: 74.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24fddb4130f60bc8de4ad4d4d3930f507070562f09a103ba19cc34e69f160178
|
|
| MD5 |
de087bf3c84eb707f5e903b6dd3329e3
|
|
| BLAKE2b-256 |
f1debcd2b7b16815fb0cddc56c7e569cbb68c4f29a49271ec53506466ebf8edb
|