Spaces:
Sleeping
Sleeping
Update app/core/cache.py
Browse files5 unmodified lines6789910111213141213141516171819181921222324252627205 unmodified linesimport timefrom app.core.config import settings
_cache = {"data": None, "timestamp": 0.0}_cache = {"data": None, "timestamp": 0}
def get_cache(): """Cache'te bulunan veri geçerliyse döndürür.""" now = time.time() if _cache["data"] is not None and (now - _cache["timestamp"] < settings.CACHE_TTL): if not _cache["data"]: return None if time.time() - _cache["timestamp"] < settings.CACHE_TTL: return _cache["data"] return None
def set_cache(data): """Yeni veriyi cache'e kaydeder."""def set_cache(data: dict): _cache["data"] = data _cache["timestamp"] = time.time()
def get_cache_age(): """Cache’in kaç saniyedir geçerli olduğunu döndürür.""" if _cache["timestamp"] == 0: return None return round(time.time() - _cache["timestamp"], 2) _cache["timestamp"] = time.time()app/core/cache.py+6-13