title: Clojure - caching with atoms?
body: <p>I have a number of threads that need to access a collection of values, some of these values also need to be persisted to a database when any changes are made to them so that I don't lose the state in case of a server reboot etc. </p>
  
  <p>Currently I'm using an <code>atom</code> to store these values, I have a set of functions which I call when something in the <code>atom</code> needs to change. </p>
  
  <p>Inside these functions I'm also persisting data to a database before calling <code>swap!</code>, I chose this approach because I need to frequently read the values inside the atom, and it doesn't seem performant to <code>open/close db connections</code> every time I'm interested in one of the values.</p>
  
  <p><strong>the question:</strong></p>
  
  <p>Is this approach viable? I'm interested to know if anyone has had success implementing a similar solution or are there pitfalls I should be aware of?</p>