瀏覽代碼

fix: only execute generator if value is not found in redis cache (#18472) (#18479)

* fix: use of generator in

* fix: improve docstring

* fix: improve docstring

* fix: directly assign value to flags

Co-authored-by: Daizy <DaizyModi>
(cherry picked from commit fce9ccedaa)

Co-authored-by: Daizy Modi <54097382+DaizyModi@users.noreply.github.com>
version-14
mergify[bot] 2 年之前
committed by GitHub
父節點
當前提交
342edb76bf
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 2 個文件被更改,包括 10 次插入6 次删除
  1. +9
    -5
      frappe/model/document.py
  2. +1
    -1
      frappe/utils/redis_wrapper.py

+ 9
- 5
frappe/model/document.py 查看文件

@@ -953,15 +953,19 @@ class Document(BaseDocument):
from frappe.email.doctype.notification.notification import evaluate_alert

if self.flags.notifications is None:
alerts = frappe.cache().hget("notifications", self.doctype)
if alerts is None:
alerts = frappe.get_all(

def _get_notifications():
"""returns enabled notifications for the current doctype"""

return frappe.get_all(
"Notification",
fields=["name", "event", "method"],
filters={"enabled": 1, "document_type": self.doctype},
)
frappe.cache().hset("notifications", self.doctype, alerts)
self.flags.notifications = alerts

self.flags.notifications = frappe.cache().hget(
"notifications", self.doctype, _get_notifications
)

if not self.flags.notifications:
return


+ 1
- 1
frappe/utils/redis_wrapper.py 查看文件

@@ -194,7 +194,7 @@ class RedisWrapper(redis.Redis):
except redis.exceptions.ConnectionError:
pass

if value:
if value is not None:
value = pickle.loads(value)
frappe.local.cache[_name][key] = value
elif generator:


Loading…
取消
儲存