title: Cassandra preventing duplicates
body: <p>I have a simple table distributed by <code>userId</code>:</p>
  
  <pre><code>create table test (
    userId uuid,
    placeId uuid,
    visitTime timestamp,
    primary key(userId, placeId, visitTime)
  ) with clustering order by (placeId asc, visitTime desc);
  </code></pre>
  
  <p>Each pair <code>(userId, placeId)</code> can have either 1 or none visits. <code>visitTime</code> is just some data associated with it, used for sorting in queries like <code>select * from test where userId = ? order by visitTime desc</code>.</p>
  
  <p>How can I require <code>(userId, placeId)</code> to be unique? I need to make sure that</p>
  
  <pre><code>insert into test (userId, placeId, timeVisit) values (?, ?, ?)
  </code></pre>
  
  <p>won't insert 2nd visit to <code>(userId, placeId)</code> with different time. Checking for existence before inserting isn't atomic, is there a better way?</p>