Module riakc_counter

Encapsulates a counter data-type.

Behaviours: riakc_datatype.

Description

Encapsulates a counter data-type. Counters are integers that can be incremented or decremented. Like the other eventually-consistent types, the original fetched value is unmodified by increments. Instead, increments are captured for later application in Riak.

Data Types

counter()

abstract datatype: counter()

counter_op()

counter_op() = {increment, integer()}

Function Index

decrement/1Decrements the counter by 1.
decrement/2Decrements the counter by the passed amount.
increment/1Increments the counter by 1.
increment/2Increments the counter by the passed amount.
is_type/1Determines whether the passed term is a counter container.
new/0Creates a new counter type with a value of 0.
new/1Creates a new counter type with the passed context.
new/2Creates a new counter type with the passed integer and context.
to_op/1Extracts the changes to this counter as an operation.
type/0Returns the symbolic name of this container.
value/1Gets the original value of the counter.

Function Details

decrement/1

decrement(Counter::counter()) -> counter()

Decrements the counter by 1.

decrement/2

decrement(Amount::integer(), Counter::counter()) -> counter()

Decrements the counter by the passed amount.

increment/1

increment(Counter::counter()) -> counter()

Increments the counter by 1.

increment/2

increment(Amount::integer(), Counter::counter()) -> counter()

Increments the counter by the passed amount.

is_type/1

is_type(T::term()) -> boolean()

Determines whether the passed term is a counter container.

new/0

new() -> counter()

Creates a new counter type with a value of 0.

new/1

new(Context::riakc_datatype:context()) -> counter()

Creates a new counter type with the passed context. It's ignored, but we need this constructor for new nested (in maps) objects on the fly

new/2

new(Value::integer(), Context::riakc_datatype:context()) -> counter()

Creates a new counter type with the passed integer and context.

to_op/1

to_op(Counter::counter()) -> riakc_datatype:update(counter_op())

Extracts the changes to this counter as an operation.

type/0

type() -> atom()

Returns the symbolic name of this container.

value/1

value(Counter::counter()) -> integer()

Gets the original value of the counter.


Generated by EDoc, Dec 16 2016, 16:38:08.