[erlang-questions] mnesia ram cache
Thu Apr 22 00:29:57 CEST 2010
Evans, Matthew wrote:
> To implement this I intend to write my own ETS cache on top of mnesia, and use table subscription to the mnesia table (mnesia:subscribe/1) so that the cache can be updated when inserts and updates occur to the master mnesia database. The cache shall be managed by a gen_server that contains LRU or similar rules to purge data to avoid it growing too much.
Something to be aware of before you get too attached to this plan: you
won't be able to maintain transactional atomicity in the cache. That
is, if, for example, some node makes changes to two tables within a
single transaction, the subscription system as of R13B04 does not have a
nice way for a subscriber to group them together. The result could be
that someone reading the cache may get one change but not the other.
This may not matter for your case if any single write leaves your
database in a consistent (or "consistent enough") state, but it's
important to know that you'll be losing that feature of mnesia. (There
is, however, a patch I wrote in R14 which addresses this exact limitation).
More information about the erlang-questions