Optimistic locking with conditional updates

As the MyStatus service becomes more popular, we're likely to see organizations beginning to create accounts that are managed by multiple people. Once we have multiple people accessing the same resource at the same time, we need to think about what might go wrong when different people try to make conflicting changes to the same piece of data.

Let's create a new account on behalf of an organization called happycorp. We'll just start with some basic information:

INSERT INTO "users" ("username", "email", "encrypted_password") VALUES ('happycorp', 'media@happycorp.com',   0x368200fa910c16cc644f3512e63b541c85fa2a3c) IF NOT EXISTS; 

We use a conditional update, of course, to ensure that we're not overwriting ...

Get Learning Apache Cassandra - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.