correct cache keys

This commit is contained in:
Emmanuel Viennet 2021-07-20 07:52:42 +03:00
parent 5b2d4e47ec
commit 783a8a5188

View File

@ -75,7 +75,7 @@ class ScoDocCache:
@classmethod
def _get_key(cls, oid):
return cls.prefix + g.scodoc_dept + oid
return g.scodoc_dept + "_" + cls.prefix + oid
@classmethod
def get(cls, oid):
@ -87,6 +87,14 @@ class ScoDocCache:
"""Store evaluation"""
return CACHE.set(cls._get_key(oid), value, timeout=cls.timeout)
@classmethod
def get_cached(cls, oid):
"""get cached object. Clients should use .get()
This function is usefull for tests, because get() may be
overloaded by subclasses.
"""
return ScoDocCache.get(oid)
@classmethod
def delete(cls, oid):
"""Remove from cache"""
@ -134,8 +142,11 @@ class AbsSemEtudCache(ScoDocCache):
C'est pourquoi il expire après timeout secondes.
Le timeout evite aussi d'éliminer explicitement ces éléments cachés lors
des suppressions d'étudiants ou de semestres.
Clé: etudid + "_" + date_debut + "_" + date_fin
Valeur: (nb_abs, nb_abs_just)
"""
prefix = "ABSE"
timeout = 60 * 60 # ttl 60 minutes