You want to say that you want the global state to be common to all sessions?
If it's that simple, just declare an atom or ref in any namespace you like and it will be available for all sessions, for example:
(def my-state (atom {:foo 1 :bar 2}))
This works because the Clojure environment persists as long as the application server continues to work, and any future requests will be able to observe / change the global state.
Having said all this, it is worth remembering that global status is often the smell of design . You should think about whether you really need it, or if you should consider another alternative (for example, pushing the general state into the database).
source
share