Skip to main content

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_ENV for 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
  • Current-loop asynchronous transaction initialization for Redis Cluster, including fail-closed command-key discovery and slot validation
  • Two-level distributed caching with Redis-first writes and optional local L1
  • At-least-once Redis stream consumption with retry, bounded concurrency, bounded pending-message recovery, safe failure dispositions, dead-letter inspection, replay, and shutdown
  • Distributed locks with explicit ownership-loss handling and opt-in renewal and fencing tokens on standalone Redis and Redis Cluster
  • Durable logical sessions with resume-token rotation, fencing, leases, idempotent delivery IDs, browser acknowledgements, and dead-letter replay

Documentation

Development

Clone the reviewed ewox-core checkout as the sibling directory ../ewox-core; Poetry resolves that exact local source while the published package metadata retains the declared ewoxcore>=1.6.42,<10.0.0 requirement.

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.

Metadata

Release files for ewoxdbredis 2.1.1

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

Source distribution (sdist)

Source distribution for ewoxdbredis 2.1.1
File Size Uploaded
ewoxdbredis-2.1.1.tar.gz 56.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ewoxdbredis 2.1.1
File Interpreter ABI Platform
ewoxdbredis-2.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 136.4 kB

Release files / ewoxdbredis-2.1.1.tar.gz

Download URL ewoxdbredis-2.1.1.tar.gz
Size 56.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5038aecc5f16beda3c9e99a539c44b37c33fd0dca6c6651f1243601a293f14a6
BLAKE2b-256 checksum
How to use checksums
56e2688c26cc0fe30d54c3bbd2f4a4ac88e235ce83b24280c178361979967da3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release files / ewoxdbredis-2.1.1-py3-none-any.whl

Download URL ewoxdbredis-2.1.1-py3-none-any.whl
Size 80.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ababe0080bfee6f8d5ac0c596829897656d3753a2adda18c5912cb5d00c94b7
BLAKE2b-256 checksum
How to use checksums
997ced8a12a28542f610601f2430991657cb5649bdfb94cc41a646475037cffc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

2.1.1 This release

2 release files

2.0.1

2 release files

1.2.27

2 release files

1.2.24

2 release files

1.2.22

2 release files

1.2.21

2 release files

1.2.20

2 release files

1.2.19

2 release files

1.2.18

2 release files

1.2.14

2 release files

1.2.12

2 release files

1.2.11

2 release files

1.2.10

2 release files

1.2.9

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

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