"""Redis configuration — loaded from environment variables.

Redis is opt-in. Set REDIS_ENABLED=true to activate.
All defaults are safe for running without Redis (REDIS_ENABLED defaults to false).
"""
from __future__ import annotations

import os

# Toggle — false by default so existing deployments are unaffected
REDIS_ENABLED: bool = os.getenv("REDIS_ENABLED", "false").lower() in ("1", "true", "yes")

# Connection
REDIS_URL: str = os.getenv("REDIS_URL", "redis://localhost:6379/0")

# TTLs (in seconds)
SESSION_TTL: int        = int(os.getenv("SESSION_TTL",        str(2 * 60 * 60)))  # 2 hours
CACHE_TTL_REGISTRY: int = int(os.getenv("CACHE_TTL_REGISTRY", str(5 * 60)))       # 5 minutes
CACHE_TTL_HISTORY: int  = int(os.getenv("CACHE_TTL_HISTORY",  str(2 * 60)))       # 2 minutes
CACHE_TTL_MEMORY: int   = int(os.getenv("CACHE_TTL_MEMORY",   str(2 * 60)))       # 2 minutes
