Refactor caching logic

This commit is contained in:
Nyymix 2025-05-16 21:27:44 +03:00
parent 4c6109a1d6
commit 01dec1e140
7 changed files with 165 additions and 122 deletions

9
gallery/cache.py Normal file
View file

@ -0,0 +1,9 @@
from django.core.cache import cache
def cached_or_set(key, timeout, func):
value = cache.get(key)
if value is None:
value = func()
cache.set(key, value, timeout)
return value