incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aaron morton <aa...@thelastpickle.com>
Subject Re: conditional update or insert
Date Sat, 02 Feb 2013 22:37:02 GMT
> Any alternative to achieve this?
Nothing server side. 
i.e. you cannot do Update foo set bar='baz' where timestamp < new_timestamp

You can monkey around with the timestamps a little though. 
Cassandra will return you the column value with the highest (internal cassandra) time stamp.
Now days most clients set this to microseconds since the unix epoch, and CQL client lets the
server set it. 

You could use your application time stamp (which I normally call sequence to avoid confusion)
as the cassandra column timestamp. If you application writes with our of order sequences,
cassandra will always return the values with the highest sequence as it will also be the cassandra
timestamp.

Hope that helps. 

-----------------
Aaron Morton
Freelance Cassandra Developer
New Zealand

@aaronmorton
http://www.thelastpickle.com

On 2/02/2013, at 7:51 AM, Jay Svc <jaytechgeek@gmail.com> wrote:

> Hi All,
> 
> On each row I have a column which maintains the timestamp like "lastUpdated" etc. 
> 
> While inserting such row I want to make sure that the row should be only updated if the
lastUpdated is older than the new one I am inserting.
> 
> One way to do this is - 
> 
> Read the record first check the timestamp if newer is latest then update.
> 
> Since I have higher volume of read and writes load. This additional read will add to
it.  
> 
> Any alternative to achieve this?
> 
> Thanks,
> Jay


Mime
View raw message