Subject: changeset in trytond:5.0 Store timestamp on Cache per database From: Cédric Krier <[email protected]>
changeset 95855b7f0426 in trytond:5.0 details: https://hg.tryton.org/trytond?cmd=changeset;node=95855b7f0426 description: Store timestamp on Cache per database The timestamp defines when the cache of a database has been cleared. issue8018 review50711002 (grafted from 2d01626c043199cf426dc052bfe2f824639e109e) diffstat: trytond/cache.py | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diffs (26 lines): diff -r d9f490511ba7 -r 95855b7f0426 trytond/cache.py --- a/trytond/cache.py Wed Jan 30 10:04:11 2019 +0100 +++ b/trytond/cache.py Wed Jan 30 10:05:55 2019 +0100 @@ -75,7 +75,7 @@ def __init__(self, name, size_limit=1024, context=True): super(MemoryCache, self).__init__(name, size_limit, context) self._cache = {} - self._timestamp = None + self._timestamp = {} self._lock = Lock() def get(self, key, default=None): @@ -120,9 +120,10 @@ for inst in cls._cache_instance: if inst._name in timestamps: with inst._lock: - if (not inst._timestamp - or timestamps[inst._name] > inst._timestamp): - inst._timestamp = timestamps[inst._name] + inst_timestamp = inst._timestamp.get(dbname) + if (not inst_timestamp + or timestamps[inst._name] > inst_timestamp): + inst._timestamp[dbname] = timestamps[inst._name] inst._cache[dbname] = LRUDict(inst.size_limit) cls._clean_last = datetime.now()
