AtomicReference

class AtomicReference(client, service_name, name)

Bases: hazelcast.proxy.base.PartitionSpecificProxy

AtomicReference is a atomically updated reference to an object.

alter(function)

Alters the currently stored reference by applying a function on it.

Parameters:function – (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual org.hazelcast.core.IFunction implementation.
apply(function)

Applies a function on the value, the actual stored value will not change.

Parameters:function – (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual org.hazelcast.core.IFunction implementation.
Returns:(object), the result of the function application.
alter_and_get(function)

Alters the currently stored reference by applying a function on it and gets the result.

Parameters:function – (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual org.hazelcast.core.IFunction implementation.
Returns:(object), the new value, the result of the applied function.
compare_and_set(expected, updated)

Atomically sets the value to the given updated value only if the current value == the expected value.

Parameters:
  • expected – (object), the expected value.
  • updated – (object), the new value.
Returns:

(bool), true if successful; or false if the actual value was not equal to the expected value.

clear()

Clears the current stored reference.

contains(expected)

Checks if the reference contains the value.

Parameters:expected – (object), the value to check (is allowed to be None).
Returns:(bool), true if the value is found, false otherwise.
get()

Gets the current value.

Returns:(object), the current value.
get_and_alter(function)

Alters the currently stored reference by applying a function on it on and gets the old value.

Parameters:function – (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual org.hazelcast.core.IFunction implementation.
Returns:(object), the old value, the value before the function is applied.
get_and_set(new_value)

Gets the old value and sets the new value.

Parameters:new_value – (object), the new value.
Returns:(object), the old value.
is_null()

Checks if the stored reference is null.

Returns:(bool), true if null, false otherwise.
set(new_value)

Atomically sets the given value.

Parameters:new_value – (object), the new value.
set_and_get(new_value)

Sets and gets the value.

Parameters:new_value – (object), the new value.
Returns:(object), the new value.