AtomicLong¶
- class AtomicLong(context, group_id, service_name, proxy_name, object_name)[source]¶
Bases:
hazelcast.proxy.cp.BaseCPProxy[BlockingAtomicLong]AtomicLong is a redundant and highly available distributed counter for 64-bit integers (
longtype in Java).It works on top of the Raft consensus algorithm. It offers linearizability during crash failures and network partitions. It is CP with respect to the CAP principle. If a network partition occurs, it remains available on at most one side of the partition.
AtomicLong implementation does not offer exactly-once / effectively-once execution semantics. It goes with at-least-once execution semantics by default and can cause an API call to be committed multiple times in case of CP member failures. It can be tuned to offer at-most-once execution semantics. Please see fail-on-indeterminate-operation-state server-side setting.
- add_and_get(delta: int) hazelcast.future.Future[int][source]¶
Atomically adds the given value to the current value.
- Parameters
delta – The value to add to the current value.
- Returns
The updated value, the given value added to the current value.
- compare_and_set(expect: int, update: int) hazelcast.future.Future[bool][source]¶
Atomically sets the value to the given updated value only if the current value equals the expected value.
- Parameters
expect – The expected value.
update – The new value.
- Returns
Trueif successful; orFalseif the actual value was not equal to the expected value.
- decrement_and_get() hazelcast.future.Future[int][source]¶
Atomically decrements the current value by one.
- Returns
The updated value, the current value decremented by one.
- get_and_decrement() hazelcast.future.Future[int][source]¶
Atomically decrements the current value by one.
- Returns
The old value.
- get() hazelcast.future.Future[int][source]¶
Gets the current value.
- Returns
The current value.
- get_and_add(delta: int) hazelcast.future.Future[int][source]¶
Atomically adds the given value to the current value.
- Parameters
delta – The value to add to the current value.
- Returns
The old value before the add.
- get_and_set(new_value: int) hazelcast.future.Future[int][source]¶
Atomically sets the given value and returns the old value.
- Parameters
new_value – The new value.
- Returns
The old value.
- increment_and_get() hazelcast.future.Future[int][source]¶
Atomically increments the current value by one.
- Returns
The updated value, the current value incremented by one.
- get_and_increment() hazelcast.future.Future[int][source]¶
Atomically increments the current value by one.
- Returns
The old value.
- set(new_value: int) hazelcast.future.Future[None][source]¶
Atomically sets the given value.
- Parameters
new_value – The new value
- alter(function: Any) hazelcast.future.Future[None][source]¶
Alters the currently stored value by applying a function on it.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function that alters the currently stored value.
- alter_and_get(function: Any) hazelcast.future.Future[int][source]¶
Alters the currently stored value by applying a function on it and gets the result.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function that alters the currently stored value.
- Returns
The new value.
- get_and_alter(function: Any) hazelcast.future.Future[int][source]¶
Alters the currently stored value by applying a function on it and gets the old value.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function that alters the currently stored value.
- Returns
The old value.
- apply(function: Any) hazelcast.future.Future[Any][source]¶
Applies a function on the value, the actual stored value will not change.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function applied to the currently stored value.
- Returns
The result of the function application.
- blocking() hazelcast.proxy.cp.atomic_long.BlockingAtomicLong[source]¶
Returns a version of this proxy with only blocking method calls.
- class BlockingAtomicLong(wrapped: hazelcast.proxy.cp.atomic_long.AtomicLong)[source]¶
Bases:
hazelcast.proxy.cp.atomic_long.AtomicLong- add_and_get(delta: int) int[source]¶
Atomically adds the given value to the current value.
- Parameters
delta – The value to add to the current value.
- Returns
The updated value, the given value added to the current value.
- compare_and_set(expect: int, update: int) bool[source]¶
Atomically sets the value to the given updated value only if the current value equals the expected value.
- Parameters
expect – The expected value.
update – The new value.
- Returns
Trueif successful; orFalseif the actual value was not equal to the expected value.
- decrement_and_get() int[source]¶
Atomically decrements the current value by one.
- Returns
The updated value, the current value decremented by one.
- get_and_decrement() int[source]¶
Atomically decrements the current value by one.
- Returns
The old value.
- get_and_add(delta: int) int[source]¶
Atomically adds the given value to the current value.
- Parameters
delta – The value to add to the current value.
- Returns
The old value before the add.
- get_and_set(new_value: int) int[source]¶
Atomically sets the given value and returns the old value.
- Parameters
new_value – The new value.
- Returns
The old value.
- increment_and_get() int[source]¶
Atomically increments the current value by one.
- Returns
The updated value, the current value incremented by one.
- get_and_increment() int[source]¶
Atomically increments the current value by one.
- Returns
The old value.
- set(new_value: int) None[source]¶
Atomically sets the given value.
- Parameters
new_value – The new value
- alter(function: Any) None[source]¶
Alters the currently stored value by applying a function on it.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function that alters the currently stored value.
- alter_and_get(function: Any) int[source]¶
Alters the currently stored value by applying a function on it and gets the result.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function that alters the currently stored value.
- Returns
The new value.
- get_and_alter(function: Any) int[source]¶
Alters the currently stored value by applying a function on it and gets the old value.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function that alters the currently stored value.
- Returns
The old value.
- apply(function: Any) Any[source]¶
Applies a function on the value, the actual stored value will not change.
Notes
functionmust be an instance of Hazelcast serializable type. It must have a counterpart registered in the server-side that implements thecom.hazelcast.core.IFunctioninterface with the actual logic of the function to be applied.- Parameters
function – The function applied to the currently stored value.
- Returns
The result of the function application.
- blocking() hazelcast.proxy.cp.atomic_long.BlockingAtomicLong[source]¶
Returns a version of this proxy with only blocking method calls.