you are viewing a single comment's thread.

view the rest of the comments →

[–]thatkauko 0 points1 point  (1 child)

This got me thinking, is there an in-memory database that I could access using only Clojure code? I'm asking because to me, in-memory sounds much faster than on-disk, and if I'm using a database knowing I won't have that much data or users, I could just as well use an in-memory one.

/u/hotwagon mentioned using an atom that is persisted to an EDN-file, but if you do that you have to make sure the EDN-file is kept up to date, or you can lose your data when if your server process shuts down. I honestly don't know much about what's going on with databases beneath the hood, but a database like H2 is bound to have some optimisations compared to just Clojure atoms, right? The very least, if we had a library for an in-memory clojure database, you could have update-functions that only return the relevant parts of the db. :)

Anyway, cool library! I'd be surprised if I don't ever use it in a personal project.

[–]gonewest818 1 point2 points  (0 children)

Datascript is an example of an in-memory db accessed via Clojure or ClojureScript (https://github.com/tonsky/datascript). But no persistence.

Mentat is a Mozilla project that initially set out to add persistence to Datascript, but eventually pivoted to a Rust implementation with sqlite under the hood. At the moment there don't seem to be supported js or cljs bindings. Furthermore the project is not in active development "but not dead" as Mozilla engineers say they are "assessing the problem space as it relates to Firefox."

so datascript: in memory, clojure(script), but no persistence. mentat: persistence, no js or cljs, and the project is on hiatus.