diff --git a/src/aging_session/memory.clj b/src/aging_session/memory.clj index e683fd6..0fa5302 100644 --- a/src/aging_session/memory.clj +++ b/src/aging_session/memory.clj @@ -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)))]