minor refactor

This commit is contained in:
Gered 2022-01-02 17:16:35 -05:00
parent ecf7bae62e
commit 1b3a988877

View file

@ -7,6 +7,11 @@
(defrecord SessionEntry [timestamp value])
(defn- unique-id
"Returns a new unique value suitable for a session ID."
[]
(str (UUID/randomUUID)))
(defn- now
"Return the current time in milliseconds."
[]
@ -67,7 +72,7 @@
(get-in @session-map [key :value]))))
(write-session [_ key data]
(let [key (or key (str (UUID/randomUUID)))]
(let [key (or key (unique-id))]
(swap! req-count inc) ; Increase the request count
(if refresh-on-write ; Write key and and update timestamp.
(swap! session-map assoc key (new-entry data))