refactor: minor cleanup / avoid repeat calls
This get+conditional set is also slightly prone to data races, but doesn't seem to be harmful as of now. Rationale: - To enable recorder one must first send a request, so this should be set long before. - While enabling we can accidentally clear cache for another worker by invalidating it, but that is kind of acceptable behaviour. We ONLY set it to False when `None` is received from Redis. Local invalidations remove it completely.
This commit is contained in:
parent
45d414fe29
commit
29733febcb
1 changed files with 3 additions and 2 deletions
|
|
@ -175,9 +175,10 @@ def normalize_query(query: str) -> str:
|
|||
|
||||
|
||||
def record(force=False):
|
||||
if frappe.client_cache.get_value(RECORDER_INTERCEPT_FLAG) or force:
|
||||
flag_value = frappe.client_cache.get_value(RECORDER_INTERCEPT_FLAG)
|
||||
if flag_value or force:
|
||||
frappe.local._recorder = Recorder(force=force)
|
||||
elif frappe.client_cache.get_value(RECORDER_INTERCEPT_FLAG) is None:
|
||||
elif flag_value is None:
|
||||
# Explicitly set it once so next requests can use client-side cache
|
||||
frappe.client_cache.set_value(RECORDER_INTERCEPT_FLAG, False)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue