Change PyMemoize to django-cache-memoize

This allows to support python 3.10
This commit is contained in:
JuniorJPDJ 2022-02-05 18:09:04 +01:00 committed by Georg Krause
commit f4964ab3ab
4 changed files with 50 additions and 35 deletions

View file

@ -1,4 +1,4 @@
import memoize.djangocache
from cache_memoize import cache_memoize
from django.urls import reverse
@ -11,9 +11,6 @@ from funkwhale_api.music import utils as music_utils
from . import stats
store = memoize.djangocache.Cache("default")
memo = memoize.Memoizer(store, namespace="instance:stats")
def get():
all_preferences = preferences.all()
@ -72,7 +69,7 @@ def get():
}
if share_stats:
getter = memo(lambda: stats.get(), max_age=600)
getter = cache_memoize(600, prefix="memoize:instance:stats")(stats.get)
statistics = getter()
data["usage"]["users"]["total"] = statistics["users"]["total"]
data["usage"]["users"]["activeHalfyear"] = statistics["users"][