perf: cache system settings in client side cache

This commit is contained in:
Ankush Menat 2025-01-06 19:35:21 +05:30
parent c14d416d19
commit 7ea0421624

View file

@ -2347,8 +2347,13 @@ def get_website_settings(key):
def get_system_settings(key: str):
"""Return the value associated with the given `key` from System Settings DocType."""
if not (system_settings := getattr(local, "system_settings", None)):
key = get_document_cache_key("System Settings", "System Settings")
try:
local.system_settings = system_settings = get_cached_doc("System Settings")
system_settings = client_cache.get_value(key)
if not system_settings:
system_settings = frappe.get_doc("System Settings")
client_cache.set_value(key, system_settings)
local.system_settings = system_settings
except DoesNotExistError: # possible during new install
clear_last_message()
return