changeset 54c45d32566f in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset;node=54c45d32566f
description:
        Clear all cache after module loaded

        As we rollback the cache modification when loading a module, we must 
clear all
        of them at the end to ensure to not keep outdated data.

        issue9759
        review339421002
diffstat:

 CHANGELOG                   |  1 +
 doc/ref/cache.rst           |  4 ++++
 trytond/cache.py            |  5 +++++
 trytond/modules/__init__.py |  3 +++
 4 files changed, 13 insertions(+), 0 deletions(-)

diffs (50 lines):

diff -r 4625f79747ab -r 54c45d32566f CHANGELOG
--- a/CHANGELOG Mon Jan 11 00:06:13 2021 +0100
+++ b/CHANGELOG Wed Jan 13 00:26:53 2021 +0100
@@ -1,3 +1,4 @@
+* Add clear_all method to Cache
 * Support Genshi element directives in HTML editor
 * Add firstline tool
 * Add support for Python 3.9
diff -r 4625f79747ab -r 54c45d32566f doc/ref/cache.rst
--- a/doc/ref/cache.rst Mon Jan 11 00:06:13 2021 +0100
+++ b/doc/ref/cache.rst Wed Jan 13 00:26:53 2021 +0100
@@ -35,6 +35,10 @@
 
 Clears all the keys in the cache.
 
+.. classmethod:: clear_all()
+
+Clears all cache instances.
+
 .. classmethod:: sync(transaction)
 
 Synchronize cache instances using transaction.
diff -r 4625f79747ab -r 54c45d32566f trytond/cache.py
--- a/trytond/cache.py  Mon Jan 11 00:06:13 2021 +0100
+++ b/trytond/cache.py  Wed Jan 13 00:26:53 2021 +0100
@@ -76,6 +76,11 @@
         raise NotImplementedError
 
     @classmethod
+    def clear_all(cls):
+        for inst in cls._instances.values():
+            inst.clear()
+
+    @classmethod
     def sync(cls, transaction):
         raise NotImplementedError
 
diff -r 4625f79747ab -r 54c45d32566f trytond/modules/__init__.py
--- a/trytond/modules/__init__.py       Mon Jan 11 00:06:13 2021 +0100
+++ b/trytond/modules/__init__.py       Wed Jan 13 00:26:53 2021 +0100
@@ -299,6 +299,9 @@
         while modules_todo:
             (module, to_delete) = modules_todo.pop()
             convert.post_import(pool, module, to_delete)
+
+        # Ensure cache is clear for other instances
+        Cache.clear_all()
     logger.info('all modules loaded')
 
 

Reply via email to