first commit

This commit is contained in:
2025-09-19 15:19:32 +05:00
commit d160410cd9
305 changed files with 9509 additions and 0 deletions

18
core/utils/cache.py Normal file
View File

@@ -0,0 +1,18 @@
import hashlib
from django.core.cache import cache
from config.env import env
class Cache:
def remember(self, func, key: str, timeout=None, *args, **kwargs):
cache_enabled = env.bool("CACHE_ENABLED")
key = hashlib.md5(key.encode("utf-8")).hexdigest()
response = cache.get(key)
if not cache_enabled:
return func(*args, **kwargs)
elif response is None:
response = func(*args, **kwargs)
cache.set(key, response, env.int("CACHE_TIME") if timeout is None else timeout)
return response