perf: use client_cache for form meta

This commit is contained in:
Ankush Menat 2025-02-25 12:14:52 +05:30
parent 7721fdb054
commit fe3e5021a4
2 changed files with 4 additions and 4 deletions

View file

@ -66,7 +66,6 @@ user_cache_keys = (
)
doctype_cache_keys = (
"doctype_form_meta",
"last_modified",
"linked_doctypes",
"workflow",

View file

@ -36,12 +36,13 @@ ASSET_KEYS = (
def get_meta(doctype, cached=True) -> "FormMeta":
# don't cache for developer mode as js files, templates may be edited
cached = cached and not frappe.conf.developer_mode
key = f"doctype_form_meta::{doctype}"
if cached:
meta = frappe.cache.hget("doctype_form_meta", doctype)
meta = frappe.client_cache.get_value(key)
if not meta:
# Cache miss - explicitly get meta from DB to avoid
# Cache miss - explicitly get meta from DB to avoid mismatches
meta = FormMeta(doctype, cached=False)
frappe.cache.hset("doctype_form_meta", doctype, meta)
frappe.client_cache.set_value(key, meta)
else:
meta = FormMeta(doctype)