Skip to content

Overview

Backendless Counters API provides a centralized server-side facility for working with values that may be updated atomically. Every counter has a name assigned to it. The name is used in all operations to identify the counter. Since the counter value is managed centrally, multiple heterogeneous clients can access and modify the value.

All counter APIs are available via Backendless.Counters.[methodname] accessor. For example, the following code increments a counter and returns the current value:

int counterValue = Backendless.Counters.IncrementAndGet( "my counter" );

Additionally, there is a shortcut approach with support for generics:

String counterName = "MyCounter";

// counter working with int values
// =====================================================
Backendless.Counters.METHODNAME<int>( args );
// or
IAtomic<int> fooCounter = Backendless.Counters.of<int>( counterName );

// counter working with long values
// =====================================================
Backendless.Counters.METHODNAME<long>( args );
// or
IAtomic<int> fooCounter = Backendless.Counters.of<int>( counterName );

Codeless Reference

codeless_atomic_counters_increment_1_return_current_2