refactor: Simpler workflow caching

Entire document is cached, so no need to create another layer of cache.
This commit is contained in:
Ankush Menat 2023-07-19 16:31:00 +05:30
parent d68e46d2cc
commit 892c5e30a2
2 changed files with 1 additions and 6 deletions

View file

@ -228,11 +228,7 @@ def send_email_alert(workflow_name):
def get_workflow_field_value(workflow_name, field):
value = frappe.cache.hget("workflow_" + workflow_name, field)
if value is None:
value = frappe.db.get_value("Workflow", workflow_name, field)
frappe.cache.hset("workflow_" + workflow_name, field, value)
return value
return frappe.get_cached_value("Workflow", workflow_name, field)
@frappe.whitelist()

View file

@ -17,7 +17,6 @@ class Workflow(Document):
def on_update(self):
self.update_doc_status()
frappe.clear_cache(doctype=self.document_type)
frappe.cache.delete_key("workflow_" + self.name) # clear cache created in model/workflow.py
def create_custom_field_for_workflow_state(self):
frappe.clear_cache(doctype=self.document_type)