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
  • 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

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

ewoxdbredis-2.0.1.tar.gz (48.2 kB view details)

Uploaded Source

Built Distribution

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

ewoxdbredis-2.0.1-py3-none-any.whl (74.0 kB view details)

Uploaded Python 3

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

Hashes for ewoxdbredis-2.0.1.tar.gz
Algorithm Hash digest
SHA256 6fb0bad0b7c13bfdf3f52286f5e81e41e4085d0801306e6797371116f84cb17e
MD5 09ef48de4948e3af964d25c48ac03113
BLAKE2b-256 05742a0805629b7b26a3c6c7b483cda46c66ffe919726fe5e496891345dacf9a

See more details on using hashes here.

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

Hashes for ewoxdbredis-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24fddb4130f60bc8de4ad4d4d3930f507070562f09a103ba19cc34e69f160178
MD5 de087bf3c84eb707f5e903b6dd3329e3
BLAKE2b-256 f1debcd2b7b16815fb0cddc56c7e569cbb68c4f29a49271ec53506466ebf8edb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 files

1.2.27

2 files

1.2.24

2 files

1.2.22

2 files

1.2.21

2 files

1.2.20

2 files

1.2.19

2 files

1.2.18

2 files

1.2.17

2 files

1.2.15

2 files

1.2.14

2 files

1.2.12

2 files

1.2.11

2 files

1.2.10

2 files

1.2.9

2 files

1.2.8

2 files

1.2.7

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

0.1.0

2 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