Spaces:
Sleeping
Sleeping
Update app/core/cache.py
Browse files5 unmodified lines67891011121314151617181920212223242526275 unmodified linesimport timefrom app.core.config import settings_cache = {"data": None, "timestamp": 0.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):return _cache["data"]return Nonedef set_cache(data):"""Yeni veriyi cache'e kaydeder."""_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 Nonereturn round(time.time() - _cache["timestamp"], 2)5 unmodified lines678910111213141516171819205 unmodified linesimport timefrom app.core.config import settings_cache = {"data": None, "timestamp": 0}def get_cache():if not _cache["data"]:return Noneif time.time() - _cache["timestamp"] < settings.CACHE_TTL:return _cache["data"]return Nonedef set_cache(data: dict):_cache["data"] = data_cache["timestamp"] = time.time()
app/core/cache.py+6-13