import os from functools import lru_cache from pydantic_redis import RedisConfig from redis import Redis host = os.environ.get("REDIS_HOST", "localhost") port = int(os.environ.get("REDIS_PORT", 6379)) password = os.environ.get("REDIS_PASSWORD", None) ssl = True if os.environ.get("REDIS_SSL") else False @lru_cache(maxsize=1) def get_redis_client(): return Redis(host=host, port=port, password=password, ssl=ssl) @lru_cache(maxsize=1) def get_redis_config(): return RedisConfig(host=host, port=port, password=password, ssl=ssl)