somewhat silly convenience function for reading all session entries

most apps won't need to do this, but i seem to be unlucky and work on
apps that do care about this kind of thing ...
This commit is contained in:
Gered 2022-01-02 19:42:55 -05:00
parent 65870439bd
commit c95a02270a
2 changed files with 14 additions and 0 deletions

View file

@ -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)))

View file

@ -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)