From 0943e13f05271544d386a3b3a528dabab371f4f7 Mon Sep 17 00:00:00 2001 From: gered Date: Wed, 5 Jan 2022 17:00:49 -0500 Subject: [PATCH] naming tweak --- src/aging_session/core.clj | 10 +++++----- test/aging_session/core_test.clj | 28 ++++++++++++++-------------- test/aging_session/performance.clj | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/aging_session/core.clj b/src/aging_session/core.clj index 9b7ff5d..edaecae 100644 --- a/src/aging_session/core.clj +++ b/src/aging_session/core.clj @@ -145,14 +145,14 @@ (recur))) (def default-opts - {:refresh-on-write true - :refresh-on-read true - :sweep-interval 30}) + {: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)) diff --git a/test/aging_session/core_test.clj b/test/aging_session/core_test.clj index f393d8e..5199123 100644 --- a/test/aging_session/core_test.clj +++ b/test/aging_session/core_test.clj @@ -9,9 +9,9 @@ (aging-memory-store 30 (merge - {:refresh-on-read true - :refresh-on-write true - :sweep-interval 15} + {:refresh-on-read? true + :refresh-on-write? true + :sweep-interval 15} opts))) (deftest basic-read-empty @@ -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,9 +125,9 @@ (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 - :sweep-interval 1 ; sweeper thread tries to run every 1 second + {: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}) (Thread/sleep 20) @@ -167,8 +167,8 @@ (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 - :sweep-interval 1 ; sweep thread tries to run every 1 second + {:refresh-on-read? true + :sweep-interval 1 ; sweep thread tries to run every 1 second })] (is (nil? (read-session as "foo")) "no session entry present for this key") diff --git a/test/aging_session/performance.clj b/test/aging_session/performance.clj index f1ca5b7..f017d9a 100644 --- a/test/aging_session/performance.clj +++ b/test/aging_session/performance.clj @@ -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 []