import os import redis.asyncio as redis from dotenv import load_dotenv load_dotenv() CACHE_URI = os.getenv("CACHE_URI") CACHE_K = os.getenv("CACHE_K") def get_redis_client(): """ Initializes and returns a Redis client instance. """ if not CACHE_URI or not CACHE_K: raise ValueError("CACHE_URI or CACHE_K is not set in the environment variables.") return redis.Redis( host=CACHE_URI.split(":")[0], port=int(CACHE_URI.split(":")[1]), password=CACHE_K, decode_responses=True, )