From dc5bbc15ce92dbff87c73ab0a4dbfc7ef5d970cf Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 25 Feb 2025 10:49:41 +0530 Subject: [PATCH] fix: Wild card cache clearing for doctypes (#31415) Clear all keys that contain doctype name. This is just a hack to avoid dealing with many random partial caches that exist. Possible improvement: - Standardize ALL doctype specific cache keys so this becomes simple. --- frappe/cache_manager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frappe/cache_manager.py b/frappe/cache_manager.py index a9d87c620f..f11b07f600 100644 --- a/frappe/cache_manager.py +++ b/frappe/cache_manager.py @@ -139,6 +139,9 @@ def _clear_doctype_cache_from_redis(doctype: str | None = None): def clear_single(dt): frappe.clear_document_cache(dt) + # Wild card for all keys containing this doctype. + # this can be excessive but this function isn't called often... ideally. + frappe.client_cache.delete_keys(f"*{dt}*") frappe.cache.hdel_names(doctype_cache_keys, dt) clear_meta_cache(dt)