fix session store init and default opts handling. how embarrassing!

cannot believe i didn't catch this earlier. whoops.
This commit is contained in:
Gered 2022-01-03 21:24:14 -05:00
parent 349dd71ce9
commit 1e4a98e946

View file

@ -114,15 +114,21 @@
(Thread/sleep sweep-interval) (Thread/sleep sweep-interval)
(recur))) (recur)))
(def default-opts
{:refresh-on-write true
:refresh-on-read true
:sweep-threshold nil
:sweep-interval 30})
(defn aging-memory-store (defn aging-memory-store
"Creates an in-memory session storage engine where entries expire after the given ttl" "Creates an in-memory session storage engine where entries expire after the given ttl"
[ttl & [opts]] [ttl & [opts]]
(let [{:keys [session-atom refresh-on-write refresh-on-read sweep-threshold sweep-interval] (let [{:keys [session-atom refresh-on-write refresh-on-read sweep-threshold sweep-interval] :as opts}
:or {session-atom (atom {}) (merge
refresh-on-write true default-opts
refresh-on-read true {:session-atom (atom {})}
sweep-threshold nil opts)
sweep-interval 30}} opts
; internally, we want time values as milliseconds. externally, it is more convenient to have them specified ; internally, we want time values as milliseconds. externally, it is more convenient to have them specified
; as seconds because, really, for sessions, no one is really going to want to specify sub-second values for ; as seconds because, really, for sessions, no one is really going to want to specify sub-second values for
; any of these times! (no, you don't really need a sweeper thread running multiple times per second ...) ; any of these times! (no, you don't really need a sweeper thread running multiple times per second ...)