Subject: changeset in trytond:4.8 Store timestamp on Cache per database From: Cédric Krier <[email protected]>
changeset 25a4a95721bd in trytond:4.8 details: https://hg.tryton.org/trytond?cmd=changeset;node=25a4a95721bd description: Store timestamp on Cache per database The timestamp defines when the cache of a database has been cleared. issue8018 review50711002 (grafted from 2d01626c043199cf426dc052bfe2f824639e109e) (grafted from 95855b7f04263def11a6924a3619aa6f9b2c55d2) diffstat: trytond/cache.py | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diffs (26 lines): diff -r f1884b59831d -r 25a4a95721bd trytond/cache.py --- a/trytond/cache.py Wed Jan 30 09:36:21 2019 +0100 +++ b/trytond/cache.py Wed Jan 30 10:05:55 2019 +0100 @@ -72,7 +72,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): @@ -115,9 +115,10 @@ for inst in Cache._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) @staticmethod
