diff --git a/CHANGELOG b/CHANGELOG index fd5066e8de..0ac3237dce 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 --git a/doc/ref/cache.rst b/doc/ref/cache.rst index b4da3cb700..12bd659b7f 100644 --- a/doc/ref/cache.rst +++ b/doc/ref/cache.rst @@ -35,6 +35,10 @@ Sets the ``value`` of the ``key`` in the cache. Clears all the keys in the cache. +.. classmethod:: clear_all() + +Clears all cache instances. + .. classmethod:: sync(transaction) Synchronize cache instances using transaction. diff --git a/trytond/cache.py b/trytond/cache.py index 489454fd88..96107a97fd 100644 --- a/trytond/cache.py +++ b/trytond/cache.py @@ -75,6 +75,11 @@ class BaseCache(object): def clear(self): raise NotImplementedError + @classmethod + def clear_all(cls): + for inst in cls._instances.values(): + inst.clear() + @classmethod def sync(cls, transaction): raise NotImplementedError diff --git a/trytond/modules/__init__.py b/trytond/modules/__init__.py index 2493a6fc3c..6fad3d12d5 100644 --- a/trytond/modules/__init__.py +++ b/trytond/modules/__init__.py @@ -299,6 +299,9 @@ def load_module_graph(graph, pool, update=None, lang=None): 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')