perf: enable client side caching for recorder flag

This commit is contained in:
Ankush Menat 2025-01-02 13:25:41 +05:30
parent 796e51df62
commit a3c48da7f4

View file

@ -175,8 +175,11 @@ def normalize_query(query: str) -> str:
def record(force=False):
if frappe.cache.get_value(RECORDER_INTERCEPT_FLAG) or force:
if frappe.client_cache.get_value(RECORDER_INTERCEPT_FLAG) or force:
frappe.local._recorder = Recorder(force=force)
elif frappe.client_cache.get_value(RECORDER_INTERCEPT_FLAG) is None:
# Explicitly set it once so next requests can use client-side cache
frappe.client_cache.set_value(RECORDER_INTERCEPT_FLAG, False)
def dump():
@ -342,14 +345,14 @@ def start(
request_filter=request_filter,
jobs_filter=jobs_filter,
).store()
frappe.cache.set_value(RECORDER_INTERCEPT_FLAG, 1, expires_in_sec=RECORDER_AUTO_DISABLE)
frappe.client_cache.set_value(RECORDER_INTERCEPT_FLAG, True)
@frappe.whitelist()
@do_not_record
@administrator_only
def stop(*args, **kwargs):
frappe.cache.delete_value(RECORDER_INTERCEPT_FLAG)
frappe.client_cache.set_value(RECORDER_INTERCEPT_FLAG, False)
frappe.enqueue(post_process, now=frappe.flags.in_test)