I’m coming up to speed on BaseX 10 and trying to understand the practical difference between using the built-in store (or a custom store) and simply saving values into a database. As far as I can tell from the docs the basic feature is the same: given e.g., a map with stuff in it, I can store the map to a database with the new db:put-value() function or to the build-in store (or a custom store) using store:put() and in both cases can get the map back.
Given that the store is automatically persistent, it seems like the obvious choice if you’re using maps as a result caching technique, so I’m wondering what the reasons would be for not using it and using a database instead.
I think the answer includes:
* Databases provide locking semantics that the store does not—the store docs are clear that the store is non-deterministic and may have side effects. So if you need to ensure locking consistency, you want to use a database. * Custom stores require that you manage any required persistence yourself, while databases are inherently persistent.
Have I missed any other important considerations?
Without taking the time to do the measuring, I’m guessing that there is negligible performance difference between using the store and a database—I’d be very surprised if the underlying implementation was not based on the same code.
In our Project Mirabel system I need to do caching of large query results, so being able to quickly and conveniently store maps is ideal and I’m very excited to take advantage of this new feature.
Cheers,
E.
_____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.comhttps://www.servicenow.com LinkedInhttps://www.linkedin.com/company/servicenow | Twitterhttps://twitter.com/servicenow | YouTubehttps://www.youtube.com/user/servicenowinc | Facebookhttps://www.facebook.com/servicenow
Hi Eliot,
Have I missed any other important considerations?
You got it right, both features are based on the same concept.
With the store module, your data is kept in main-memory until your BaseX instance is closed, so you can take full advantage of it in the context of server applications. It is not possible to keep multiple stores open at the same time, though. If you have contents that are related to specific databases, and if you have multiple users accessing your data, it is advisable to store them directly in the database.
If you create temporary data with BaseX and use it as a standalone tool, or if you work with a single user and a single database, it doesn’t make a big difference which feature you use.
Hope this helps, Christian
basex-talk@mailman.uni-konstanz.de