问题描述
我想知道Couchbase是否支持一致的增量计数器。根据我在,它没有,它只是封装了一个读/写操作,因此您无需自己进行操作。当然这对我不起作用,因为自从您从数据库读取数据以来,数据可能会发生变化。
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确实做到了,就像memcached和Membase Server一样,它在集群内原子地支持incr / decr操作。
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既在写又返回结果值。
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!
这篇关于Couchbase中的原子计数器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!