diff --git a/src/aging_session/memory.clj b/src/aging_session/memory.clj index c51a86b..551b106 100644 --- a/src/aging_session/memory.clj +++ b/src/aging_session/memory.clj @@ -129,3 +129,8 @@ (if store (.interrupt ^Thread (.thread store)))) +(defn get-all-sessions + "Convenience function that returns all the session entries currently in the aging-memory-store provided." + [^MemoryAgingStore store] + (if store + @(.session_atom store))) diff --git a/test/aging_session/memory_test.clj b/test/aging_session/memory_test.clj index a504834..545d86e 100644 --- a/test/aging_session/memory_test.clj +++ b/test/aging_session/memory_test.clj @@ -225,4 +225,13 @@ (is (not (.isAlive ^Thread (:thread as))) "sweeper thread is no longer alive"))) +(deftest can-get-all-sessions + (let [as (->basic-aging-memory-store)] + (write-session as "a" {:foo 1}) + (write-session as "b" {:bar 2}) + (let [sessions (get-all-sessions as)] + (is (= 2 (count sessions))) + (is (= (get-in sessions ["a" :value]) {:foo 1})) + (is (= (get-in sessions ["b" :value]) {:bar 2}))))) + #_(run-tests)