From 2de16cf0f4b806f5c2f90d740df65db04e37b08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 12 Jul 2021 23:14:32 +0200 Subject: [PATCH] Do not reset cache on commit and clear When a transaction is committed indeed a new transaction is started. So we do not need to use a transaction cache just because a commit was sent because the started_at is reset to a higher time. This same logic applies to a rollback. issue10528 review365521003 --- trytond/cache.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/trytond/cache.py b/trytond/cache.py index f6ee02b099..7518af3883 100644 --- a/trytond/cache.py +++ b/trytond/cache.py @@ -250,7 +250,7 @@ class MemoryCache(BaseCache): @classmethod def commit(cls, transaction): table = Table(cls._table) - reset = cls._reset.setdefault(transaction, set()) + reset = cls._reset.pop(transaction, None) if not reset: return database = transaction.database @@ -303,10 +303,7 @@ class MemoryCache(BaseCache): @classmethod def rollback(cls, transaction): - try: - cls._reset[transaction].clear() - except KeyError: - pass + cls._reset.pop(transaction, None) @classmethod def drop(cls, dbname):