optimization for when the session entry doesn't exist

an easy and very significant performance boost for this scenario ...
This commit is contained in:
Gered 2022-01-02 16:19:34 -05:00
parent a79fed3246
commit 38c6a37d59

View file

@ -56,11 +56,12 @@
SessionStore
(read-session [_ key]
(let [ts (now)]
(swap! session-map sweep-entry ts ttl key)
(when (and refresh-on-read (contains? @session-map key))
(swap! session-map assoc-in [key :timestamp] ts))
(get-in @session-map [key :value])))
(when (contains? @session-map key)
(let [ts (now)]
(swap! session-map sweep-entry ts ttl key)
(when (and refresh-on-read (contains? @session-map key))
(swap! session-map assoc-in [key :timestamp] ts))
(get-in @session-map [key :value]))))
(write-session [_ key data]
(let [key (or key (str (UUID/randomUUID)))]