sasa1977 / con_cache

ets based key/value cache with row level isolated writes and ttl support
MIT License
910 stars 71 forks source link

Question: does this work across nodes? #38

Closed jonathanleang closed 7 years ago

sasa1977 commented 7 years ago

No, ConCache is not a distributed cache. It is powered by ets, so it only works in a scope of a single node. You can of course run one ConCache instance per each node and somehow synchronize the data or forward lookup/store operations to the proper node. However, how is this exactly supposed to be done is outside of the scope of ConCache.

jonathanleang commented 7 years ago

do you know which library I should look in to for something like that ?

sasa1977 commented 7 years ago

This is the space where the whole ecosystem could use improvements. There are some solutions, but it's sort of not immediately clear how to start.

One possible solution is riak_core. This is the library which powered the Riak distributed database, and I believe in terms of algorithms that it's really solid. The bad news is that there are no clear and simple docs (as far as I know). Also, AFAIK Basho is not operating anymore, so the library is now maintained in a separate fork. Either way, a good place to find out more is this excellent talk. The repo which is linked on hex.pm is the fork where there's a lot of active development, so you may want to ask for help there.

Another option is to use mnesia. With mnesia, it is possible to setup replicated tables (in-memory as well as disk based). You store the data on one node and it's replicated on all. The problem with mnesia is that it doesn't handle netsplits (though it provides the hooks for that), so you'll need to handle that yourself, or reach for something like this.

There are some possible other solutions that could be helpful in some situations, such as Phoenix presence for example. I'd also advise asking around on elixirforum.com. I haven't been following this space closely for some time, so maybe some other solutions have emerged.

jonathanleang commented 7 years ago

@sasa1977 Thank you for your suggestions. 👍