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