Counter

class Counter

A counter backed by a document on Couchbase Server.

Counter operations are atomic with respect to a single Couchbase Server cluster, but not between clusters when Cross-Datacenter Replication (XDCR) is used.

The content of a counter document is a single JSON integer with a minimum value of zero and a maximum value of 2^64 - 1.

A counter decremented below zero is reset to zero.

A counter incremented above 2^64 - 1 overflows (wraps around).

Counter values above 2^53 - 1 may have interoperability issues with other languages that store all numbers as floating point values.

See also

Functions

addAndGet
Link copied to clipboard
suspend fun addAndGet(delta: Long): ULong

Atomically adds the given delta to the current value.

decrementAndGet
Link copied to clipboard
suspend fun decrementAndGet(): ULong

Atomically decrements by one the current value.

get
Link copied to clipboard
suspend fun get(): ULong

Returns the current value of the counter.

incrementAndGet
Link copied to clipboard
suspend fun incrementAndGet(): ULong

Atomically increments by one the current value.

set
Link copied to clipboard
suspend fun set(value: ULong): MutationResult

Sets the value of the counter.

toString
Link copied to clipboard
open override fun toString(): String

Properties

collection
Link copied to clipboard
val collection: Collection
common
Link copied to clipboard
val common: CommonOptions
documentId
Link copied to clipboard
val documentId: String
durability
Link copied to clipboard
val durability: Durability
expiry
Link copied to clipboard
val expiry: Expiry