Atomic counters in Couchbase
couchbase, nosql
Solution
Couchbase absolutely does, just like memcached and Membase Server, it supports the incr/decr operations atomically within a cluster.
cb.set("mykey", 1)
x = cb.incr("mykey")
puts x #=> 2
incr is both writing and returning the resulting value.
"The update operation occurs on the server and is provided at the protocol level." means that it is atomic on the cluster, and executed by the server.
"This simplifies what would otherwise be a two-stage get and set operation." means that instead of a two-stage operation, it is a single operation!
Problem
I wanted to know if Couchbase support consistent incremental Counters. From what I've read in this doc, it does not, it just encapsulates a read/write operation so you won't need to do it yourself. Of course this doesn't work for me because the data might change since the time you read the data from the database.