Fork me on GitHub

Hi everyone! I have a quick question. Is it possible to access the contents of ring.middleware.session.memory/memory-store without passing a predefined atom? I know I can access the data if I define an atom and pass that as argument to memory-store. If I don't then the function creates an unnamed atom, how do I access the unnamed atom? It only returns the following without me being able to access it. #object [ring.middleware.session.memory.MemoryStore 0x1295a8d0 "ring.middleware.session.memory.MemoryStore@1295a8d0"]


do you want that for debugging or what do you want to do with that?


What I want to do in the end is get the ips that are logged in and the session count per ip.


Is that information going to be available in your session? I feel like you should use a separate mechanism for getting these stats. But you could use something like this as a workaround:

  (def ms (memory-store))
  (.write-session ms "k" "val")
  (.read-session ms "k")
  (.write-session ms "k2" "val2")

  (.session_map ms)
  ;; => #atom[{"k" "val", "k2" "val2"} 0x7f51bf9]



Thanks! the (.session_map X) was exactly what I was looking for


no idea why i couldnt find that with google


Of course, this relies on an implementation detail 🙂 I just used cider-inspect in emacs to look at the contents of ms var.


I use Calva in VSCode, no clue how to do cider-inspect there


Maybe it's not as easy. This one is less convenient but I used to use it a while ago:

(->> (clojure.reflect/reflect ms) :members (sort-by :name) (clojure.pprint/print-table [:name :flags :parameter-types :return-type]))


That works, thanks! Looking at the output I was close, but not close enough haha


(vec (.getMethods (.getClass session-store))) found some of them, but didnt include session_map