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.
This commit is contained in:
Ankush Menat 2025-02-25 10:49:41 +05:30 committed by GitHub
parent 55ad9c9c94
commit dc5bbc15ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)