lily_website

๐Ÿ“„ Redis Container

โฌ…๏ธ Back ๐Ÿ  Docs Root

The RedisContainer is a centralized entry point for all Redis-related managers and services. It provides a unified interface for the botโ€™s data persistence layer.

๐Ÿ› ๏ธ Class: RedisContainer

Located in: src/telegram_bot/infrastructure/redis/container.py

This container is initialized once and injected into the botโ€™s dependency injection (DI) system, making it accessible to all orchestrators and services.

๐Ÿ” Core Components

๐Ÿงฉ Why is this needed?

  1. Single Source of Truth: All Redis logic is grouped here, making it easy to manage connections and shared services.
  2. Dependency Injection: By injecting the container, we ensure that all parts of the bot use the same Redis client and manager instances.
  3. Decoupling: Orchestrators donโ€™t need to know how Redis keys are generated or how data is serialized; they simply call methods on the containerโ€™s managers.

๐Ÿ“ Usage Example

# Accessing the container from an orchestrator
await self.container.redis.appointment_cache.save(appointment_id, data)
await self.container.redis.sender.save_coordinates(chat_id, message_id)