From 60a3c41c7a866b3551d66bf30f5953f8e6c1377a Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Thu, 26 Dec 2024 18:08:14 +0530 Subject: [PATCH] perf: Avoid storing redundant information - last session update (#28922) Session contains the same exact information, so why do we need this? --- frappe/sessions.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frappe/sessions.py b/frappe/sessions.py index c114eb1cc5..395ffd73d0 100644 --- a/frappe/sessions.py +++ b/frappe/sessions.py @@ -98,7 +98,6 @@ def delete_session(sid=None, user=None, reason="Session Expired"): frappe.db.commit() frappe.cache.hdel("session", sid) - frappe.cache.hdel("last_db_session_update", sid) def clear_all_sessions(reason=None): @@ -391,7 +390,7 @@ class Session: Sessions = frappe.qb.DocType("Sessions") # update session in db - last_updated = frappe.cache.hget("last_db_session_update", self.sid) + last_updated = self.data.data.last_updated time_diff = frappe.utils.time_diff_in_seconds(now, last_updated) if last_updated else None # database persistence is secondary, don't update it too often @@ -414,8 +413,6 @@ class Session: frappe.db.commit() updated_in_db = True - - frappe.cache.hset("last_db_session_update", self.sid, now) frappe.cache.hset("session", self.sid, self.data) return updated_in_db