Spaces:
Sleeping
Sleeping
| # ===================================================== | |
| # app/core/cache.py | |
| # RAM tabanlı basit cache yönetimi | |
| # ===================================================== | |
| import time | |
| from app.core.config import settings | |
| _cache = {"data": None, "timestamp": 0} | |
| def get_cache(): | |
| if not _cache["data"]: | |
| return None | |
| if time.time() - _cache["timestamp"] < settings.CACHE_TTL: | |
| return _cache["data"] | |
| return None | |
| def set_cache(data: dict): | |
| _cache["data"] = data | |
| _cache["timestamp"] = time.time() |