perf: Avoid storing redundant information - last session update (#28922)

Session contains the same exact information, so why do we need this?
This commit is contained in:
Ankush Menat 2024-12-26 18:08:14 +05:30 committed by GitHub
parent 3ab2c2fbcf
commit 60a3c41c7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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