5

Does cassandra support an atomic get and set for a counter? I.e.

create table c(id int, value counter, primary key (id));

update update c set value=value+1 where id=1;

ok, now my counter is ready. But I want to be able to read a unique value from several servers, each server getting a distinct value, like

select value from c where id=1; 
Vikram Patil
  • 628
  • 6
  • 20
kostas.kougios
  • 945
  • 10
  • 21
  • Is there is any solution for the case that have mentioned for @Oleksi answer. I am in need of the same logic. I need to update counter value (currently cnt=8, query is cnt=cnt+1) and need to get old value(8) or new value(9) by the same query itself. So that if multiple thread tries to increment the counter type each thread will get distinct value. Is it possible to do so? Or any work around?? – Jaya Ananthram Jan 10 '15 at 13:33
  • See also https://stackoverflow.com/a/29391877/32453 – rogerdpack Feb 08 '18 at 22:52
  • @JayaAnanthram have you got answer to your question? I also need the same solution – hrishikesh chaudhari Jul 28 '22 at 05:41

0 Answers0