fix: Avoid doc caching if for_update is set (#22203)

* refactor: Avoid doc caching if for_update is set

* chore: simplify condition

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
This commit is contained in:
niraj gautam 2023-08-25 19:35:32 +05:30 committed by GitHub
parent fdcfb82f47
commit db61deef72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1254,7 +1254,7 @@ def get_doc(*args, **kwargs):
doc = frappe.model.document.get_doc(*args, **kwargs)
# Replace cache if stale one exists
if (key := can_cache_doc(args)) and cache.exists(key):
if not kwargs.get("for_update") and (key := can_cache_doc(args)) and cache.exists(key):
_set_document_in_cache(key, doc)
return doc