Hi Kevin

Have you looked at Cassandra's lightweight transactions? It sounds like they 
might work for you 
http://www.datastax.com/documentation/cassandra/2.0/cassandra/dml/dml_ltwt_transaction_c.html.
 

--
Daniel

> On 17/11/2014, at 1:51 pm, Kevin Burton <bur...@spinn3r.com> wrote:
> 
> I’m trying to have some code acquire a lock by first at performing a table 
> mutation, and then if it wins, performing a second table insert.
> 
> I don’t think this is possible with batches though.
> 
> I don’t think I can say “update this table, and if you are able to set the 
> value, and the value doesn’t already exist, then insert into this other table”
> 
> I can do this in Java code, but it’s not transactional.  Which is fine of 
> course, I can work around some code to make it safe.  
> 
> My plan B is to perform a conditional update by doing an IF NOT EXISTS and if 
> I win then I can do the insert but only for a limited time while I hold the 
> lock.  
> 
> But I don’t know if even this is possible without a write then read because 
> the datastax driver doesn’t allow me to read the values that were written.  
> I’d have to do another SELECT to read them back out.  
> 
> -- 
> Founder/CEO Spinn3r.com
> Location: San Francisco, CA
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> 

Reply via email to