April 2017
Beginner to intermediate
360 pages
9h 35m
English
Version 3.1 of CQL introduced new support for lightweight transactions, which allow us to modify data only if certain conditions are met. Unlike the application-level integrity checks we discussed earlier, lightweight transactions are safe in concurrent environments. If two processes attempt to conditionally create a row with the same key, lightweight transactions guarantee that only one will succeed.
To perform a conditional insert, we simply add the clause IF NOT EXISTS to the end of the INSERT statement. Let's start fresh with a new user account, frank:
INSERT INTO "users" ("username", "email", "encrypted_password", "location") VALUES ('frank', 'frank@gmail.com', 0xa71451665e16d8c6e6edfd444c60156efc861432, ...Read now
Unlock full access