Counter design in Cassandra
<p>I am trying to create a design where multiple C++ services will keep counters in a database, something like below:</p>

<pre><code>CREATE TABLE page_view_counts
    (url_name varchar,
     counter_value counter,
     threshold_value int,
     status int,
    PRIMARY_KEY (url_name)
    );
</code></pre>

<p>I am thinking to use Cassandra but I am not sure if Cassandra can support the following operation in an atomic way to support concurrency of the multiple service instances:</p>

<pre><code>READ counter_value
IF counter_value &gt; threshold_value
  SET status = 1 (BLOCKED)
ELSE
  SET counter_value++
</code></pre>

<p>I have seen Cassandra counter (<a href="https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_counter_t.html" rel="nofollow">https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_counter_t.html</a>)
but it seems that it cannot support the READ operation - it just ensures that you can increase the counter by some value (without knowing the previous state).</p>

<p>Is there any way for Cassandra? Should I go for a different database choice that can support the above? Should I use Cassandra and keep counters in a Redis memory and update Cassandra in a second step?</p>