naming tweak
This commit is contained in:
parent
20b4067188
commit
0943e13f05
|
@ -145,14 +145,14 @@
|
|||
(recur)))
|
||||
|
||||
(def default-opts
|
||||
{:refresh-on-write true
|
||||
:refresh-on-read true
|
||||
{:refresh-on-write? true
|
||||
:refresh-on-read? true
|
||||
:sweep-interval 30})
|
||||
|
||||
(defn aging-memory-store
|
||||
"Creates an in-memory session storage engine where entries expire after the given ttl"
|
||||
[ttl & [opts]]
|
||||
(let [{:keys [session-atom refresh-on-write refresh-on-read sweep-interval on-removal] :as opts}
|
||||
(let [{:keys [session-atom refresh-on-write? refresh-on-read? sweep-interval on-removal] :as opts}
|
||||
(merge
|
||||
default-opts
|
||||
{:session-atom (atom {})}
|
||||
|
@ -170,7 +170,7 @@
|
|||
(sweeper-thread session-atom ttl sweep-interval on-removal)
|
||||
(catch InterruptedException e))))
|
||||
store (MemoryAgingStore.
|
||||
session-atom thread ttl refresh-on-write refresh-on-read on-removal)]
|
||||
session-atom thread ttl refresh-on-write? refresh-on-read? on-removal)]
|
||||
(.start thread)
|
||||
store))
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
(aging-memory-store
|
||||
30
|
||||
(merge
|
||||
{:refresh-on-read true
|
||||
:refresh-on-write true
|
||||
{:refresh-on-read? true
|
||||
:refresh-on-write? true
|
||||
:sweep-interval 15}
|
||||
opts)))
|
||||
|
||||
|
@ -43,8 +43,8 @@
|
|||
(deftest timestamp-on-creation
|
||||
(testing "Test the behaviour where each entry's timestamp is set only on session creation."
|
||||
(let [as (->basic-aging-memory-store
|
||||
{:refresh-on-read false
|
||||
:refresh-on-write false})]
|
||||
{:refresh-on-read? false
|
||||
:refresh-on-write? false})]
|
||||
(write-session as "mykey" {:foo 1})
|
||||
(let [ts1 (read-timestamp as "mykey")]
|
||||
(is (integer? ts1)
|
||||
|
@ -59,8 +59,8 @@
|
|||
(deftest timestamp-on-write-only
|
||||
(testing "Test the behaviour where each entry's timestamp is refreshed on write (not read)."
|
||||
(let [as (->basic-aging-memory-store
|
||||
{:refresh-on-read false
|
||||
:refresh-on-write true})]
|
||||
{:refresh-on-read? false
|
||||
:refresh-on-write? true})]
|
||||
(write-session as "mykey" {:foo 1})
|
||||
(let [ts1 (read-timestamp as "mykey")]
|
||||
(is (integer? ts1)
|
||||
|
@ -80,8 +80,8 @@
|
|||
(deftest timestamp-on-read-only
|
||||
(testing "Test the behaviour where each entry's timestamp is refreshed on read (not write)."
|
||||
(let [as (->basic-aging-memory-store
|
||||
{:refresh-on-read true
|
||||
:refresh-on-write false})]
|
||||
{:refresh-on-read? true
|
||||
:refresh-on-write? false})]
|
||||
(write-session as "mykey" {:foo 1})
|
||||
(let [ts1 (read-timestamp as "mykey")]
|
||||
(is (integer? ts1)
|
||||
|
@ -125,8 +125,8 @@
|
|||
(testing "Sweeper thread expires entries whenever it runs."
|
||||
(let [as (aging-memory-store
|
||||
1 ; expire after 1 second
|
||||
{:refresh-on-read true
|
||||
:refresh-on-write true
|
||||
{:refresh-on-read? true
|
||||
:refresh-on-write? true
|
||||
:sweep-interval 1 ; sweeper thread tries to run every 1 second
|
||||
})]
|
||||
(write-session as "mykey" {:foo 1})
|
||||
|
@ -167,7 +167,7 @@
|
|||
(testing "Test an empty session read (with refresh-on-read enabled) then check that the expiry sweep still works"
|
||||
(let [as (aging-memory-store
|
||||
1 ; expire after 1 second
|
||||
{:refresh-on-read true
|
||||
{:refresh-on-read? true
|
||||
:sweep-interval 1 ; sweep thread tries to run every 1 second
|
||||
})]
|
||||
(is (nil? (read-session as "foo"))
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
[ttl]
|
||||
(aging-memory-store
|
||||
ttl
|
||||
{:refresh-on-write true
|
||||
:refresh-on-read true}))
|
||||
{:refresh-on-write? true
|
||||
:refresh-on-read? true}))
|
||||
|
||||
(defn check-nonexistent-read
|
||||
[]
|
||||
|
|
Loading…
Reference in a new issue