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.
相关问题
- Couchbase & Spring query error: “Query returning a
- Issues when replicating from couchbase bucket to e
- MongoDB: groupby subdocument and count + add total
- Does using non-SQL databases obviate the need for
- Querying with “contains” on a list of user defined
相关文章
- How does Cassandra scale horizontally ?
- Modelling a Chat like Application in Firebase
- Bucket password in Couchbase
- NoSQL Injection? (PHP->phpcassa->Cassandra)
- Connect Parse with external database?
- Does using NoSQL make sense for a non-distributed
- How to query nested keys in Riak?
- (Non-Relational) DBMS Design Resource
Couchbase absolutely does, just like memcached and Membase Server, it supports the incr/decr operations atomically within a cluster.
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!
If you are using the Java API, since the release of version 2.0, the incr methods has been replaced by the counter method.
You would need to use the counter method of your bucket. This method allows you to define the name of the counter document (which holds a long type) and the increment. If the doc does not exists, it creates it. Many other parameters are defined in the official documentation.
This operation is atomic, so feel safe to use counters. http://docs.couchbase.com/developer/java-2.0/documents-atomic.html