Calling do_count_hit will return {:ok, count} if the bucket was already created. If a bucket needed to be created (i.e. the first time this is called), do_count_hit would always return {:ok, 1}.
The counts are stored correctly, but the initial return is misleading. Here's an example of what we have in production.
First call costs 30, but since {:ok, 1} was returned, we let the user know that they still have 599 points left:
The next call also costs 30, but since {:ok, 60} was returned, we're able to correctly inform the user of the cost:
Coverage remained the same at 80.357% when pulling 913e78cd417deeafc050d48eff472d5f5dcf6238 on davelively14:dl-return-increment-on-create into 8cc4a28a2debcc6448a29d86b6c787d3f7289527 on ExHammer:master.
Calling
do_count_hit
will return{:ok, count}
if the bucket was already created. If a bucket needed to be created (i.e. the first time this is called),do_count_hit
would always return{:ok, 1}
.The counts are stored correctly, but the initial return is misleading. Here's an example of what we have in production.
First call costs 30, but since
{:ok, 1}
was returned, we let the user know that they still have 599 points left:The next call also costs 30, but since
{:ok, 60}
was returned, we're able to correctly inform the user of the cost: