Rafael Mor
Rafael Mor

Reputation: 686

Cassandra read before write/update

What is the fastest way to read before write? I've a Import script that's load about 10-15K emails and I need to check if they exists or not, Is there a way to write and see if it's overwrite other data? Or I just need to do read before write?

Thanks.

Upvotes: 1

Views: 857

Answers (1)

Roman Tumaykin
Roman Tumaykin

Reputation: 1931

If you don't care to overwrite an email then you dont need any reads as insert and update are synonyms. If you do then you can use lightweight transactions (INSERT ... IF NOT EXISTS). If a record with a given key exists then it will not be overwritten. You can add a column to the table where an application will pass a unique value. Once you insert data you call SELECT and compare the value of that column with the value that was passed. If they match then this record was created by your call. If not then it was created by some other process

Upvotes: 2

Related Questions