From 783a8a5188c38d77e323ccb2333c356b8c5ecd68 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 20 Jul 2021 07:52:42 +0300 Subject: [PATCH] correct cache keys --- app/scodoc/sco_cache.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index 1137e68dba..826d662d00 100644 --- a/app/scodoc/sco_cache.py +++ b/app/scodoc/sco_cache.py @@ -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