diff --git a/app/scodoc/sco_cache.py b/app/scodoc/sco_cache.py index 1137e68db..826d662d0 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