perf: Evict site cache only on frappe.clear_cache() (#29033)

For doctype/user specific cache eviction, no need to remove site_cache.

Rationale:
- Site cache is worker specific, so this eviction doesn't help much.
- Anything that might need to be evicted from site cache should be
  manually cleared or use a TTL.

Maybe we can just replace all of site_cache usage with
https://github.com/frappe/frappe/pull/28992 once it's stable.
This commit is contained in:
Ankush Menat 2025-01-03 11:38:53 +05:30 committed by GitHub
parent 241eb095ce
commit 46dbb2f0cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -968,7 +968,9 @@ def clear_cache(user: str | None = None, doctype: str | None = None):
for fn in get_hooks("clear_cache"):
get_attr(fn)()
frappe.utils.caching._SITE_CACHE.clear()
if (not doctype and not user) or doctype == "DocType":
frappe.utils.caching._SITE_CACHE.clear()
local.role_permissions = {}
if hasattr(local, "request_cache"):
local.request_cache.clear()