Search code examples
databasemultithreadingclojurering

Using atom as in-memory database in ring website


I'm trying to build a very simple wiki-like system in Clojure and serving the http using Ring.

Instead of using a regular database i was thinking about using just an atom and serialise it to a file when it gets changed. Something like https://github.com/alandipert/enduro just with a delayed write.

Having the data in-mem in vectors and maps will surely make the service faster and the code simpler/more intuitive to write?

Will that work with a multithreaded Jetty/Ring server?

The content of the atom will surely fit in memory for now, but that might not hold true in the future. Any ideas to how i can structure the code to make it easier to switch to an alternative storage backend in the future?


Solution

  • This is the best guide for keeping data in memory and storing it to a single file: http://www.brandonbloom.name/blog/2013/06/26/slurp-and-spit/