From a8a058ed643716668b015564624a89581a3a9e06 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 7 Feb 2023 23:31:56 +1100 Subject: [PATCH] Add option to specify cache attribute when loading a plugin setting (#4315) - Default to no cache (perform DB hit) --- InvenTree/plugin/base/integration/mixins.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/InvenTree/plugin/base/integration/mixins.py b/InvenTree/plugin/base/integration/mixins.py index 0e2279d7cc..f8280e9bd8 100644 --- a/InvenTree/plugin/base/integration/mixins.py +++ b/InvenTree/plugin/base/integration/mixins.py @@ -35,9 +35,14 @@ class SettingsMixin: """Does this plugin use custom global settings.""" return bool(self.settings) - def get_setting(self, key): - """Return the 'value' of the setting associated with this plugin.""" - return PluginSetting.get_setting(key, plugin=self) + def get_setting(self, key, cache=False): + """Return the 'value' of the setting associated with this plugin. + + Arguments: + key: The 'name' of the setting value to be retrieved + cache: Whether to use RAM cached value (default = False) + """ + return PluginSetting.get_setting(key, plugin=self, cache=cache) def set_setting(self, key, value, user=None): """Set plugin setting value by key."""