Add media folder size to admin template

This commit is contained in:
Nyymix 2025-09-18 10:31:58 +03:00
parent 21e5b8a676
commit 376482e965
4 changed files with 37 additions and 4 deletions

View file

@ -7,3 +7,20 @@ def cached_or_set(key, timeout, func):
value = func()
cache.set(key, value, timeout)
return value
def cached_or_set_locked(key, timeout, func):
value = cache.get(key)
if value is None:
if cache.add(f"{key}:lock", True, 30): # 30s lukko
value = func()
cache.set(key, value, timeout)
cache.delete(f"{key}:lock")
else:
import time
for _ in range(10): # max 1s odotus
value = cache.get(key)
if value is not None:
break
time.sleep(0.1)
return value