[erlang-questions] ets:update_counter/3 optimal settings

Max Lapshin max.lapshin@REDACTED
Fri Jun 9 15:47:16 CEST 2017


Sometimes may help something like:


ets:update_counter(Table, Key, [{#record.field, 0}, {#record.field,
-10000000000, 0, 0}]).


On Fri, Jun 9, 2017 at 9:08 AM, Alex S. <alex0player@REDACTED> wrote:

> Sounds right to me, with the caveat that read + reset to zero can lose
> some data if you are preempted between those two calls. My usual approach
> is read and decrement by -N, where N is the value I just read.
>
> 9 июня 2017 г., в 8:44, Frank Muller <frank.muller.erl@REDACTED>
> написал(а):
>
> Hi Everyone,
>
> I've some troubles to understand the optimal settings for this little
> simple problem:
>
> Two Erlang processes A and B.
>
> 1. Process A randomly increments a counter during its lifetime using "ets
> :update_counter/3"
>
> 2. Process B reads the counter every X seconds and reset it to 0.
>
> I decided to use these options when creating the table:
>
> {write_concurrency, true}, %% A and B
> {read_concurrency, false}  %% only B
>
> Are these settings correct and more importantly "optimal" (please
> elaborate your answer)?
>
> /Frank
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170609/7f48aca8/attachment.htm>


More information about the erlang-questions mailing list