Spaces:
Sleeping
Sleeping
File size: 542 Bytes
97d8bb5 00cf2e5 97d8bb5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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,
) |