Spaces:
Sleeping
Sleeping
Download app/utils/cache.py from bmsadmin/bookmyservice-ams: direct link, hf CLI and curl.
- Browser
- Download file 542 Bytes
-
https://huggingface.co/spaces/bmsadmin/bookmyservice-ams/resolve/main/app/utils/cache.py
- Command line
-
hf download hf://spaces/bmsadmin/bookmyservice-ams/app/utils/cache.py
-
curl -L -o cache.py https://huggingface.co/spaces/bmsadmin/bookmyservice-ams/resolve/main/app/utils/cache.py
542 Bytes
| 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, | |
| ) |