[erlang-questions] Cross OTP version compare-and-swap semantic on ETS
Thu Oct 12 10:17:21 CEST 2017
On 12 October 2017 at 09:01, Benoit Chesneau <bchesneau@REDACTED> wrote:
> Hi all,
> I’m looking on the best way (in term of concurrency and response speed) to
> provide a equivalent of compare-and-swap semantic on differs Erlang version
> with ETS.
> For now what I do is using `select_replace/2` on OTP 20 and for other
> versions I’m using a pen_server to serialise the writes on this values,
> making this gen_server a bottle neck. Which is fine for a small list of
> keys to update. I didn’t find any other solution to do it right now. But
> maybe someone has an idea?
The only thing I can think of is to partition the key space and use
multiple ETS tables (with a dedicated process for each).
Also something I’m currently missing is the possibility do the dame for
> delete. `select_delete` isn’t atomic right?
Not sure what you mean by 'atomic' here. I expect ETS will delete whatever
entries have matched this specified pattern at that point in time. In the
context of ETS operations, the consideration of whether it is 'atomic' or
not makes sense in the 'insert', 'replace' or 'update' scenario.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions