ReplicatedMap

class ReplicatedMap(service_name, name, context)

Bases: hazelcast.proxy.base.Proxy

A ReplicatedMap is a map-like data structure with weak consistency and values locally stored on every node of the cluster.

Whenever a value is written asynchronously, the new value will be internally distributed to all existing cluster members, and eventually every node will have the new value.

When a new node joins the cluster, the new node initially will request existing values from older nodes and replicate them locally.

add_entry_listener(key=None, predicate=None, added_func=None, removed_func=None, updated_func=None, evicted_func=None, clear_all_func=None)

Adds a continuous entry listener for this map.

Listener will get notified for map events filtered with given parameters.

Parameters
  • key – Key for filtering the events.

  • predicate (hazelcast.predicate.Predicate) – Predicate for filtering the events.

  • added_func (function) – Function to be called when an entry is added to map.

  • removed_func (function) – Function to be called when an entry is removed from map.

  • updated_func (function) – Function to be called when an entry is updated.

  • evicted_func (function) – Function to be called when an entry is evicted from map.

  • clear_all_func (function) – Function to be called when entries are cleared from map.

Returns

A registration id which is used as a key to remove the listener.

Return type

hazelcast.future.Future[str]

clear()

Wipes data out of the replicated map.

Returns

Return type

hazelcast.future.Future[None]

contains_key(key)

Determines whether this map contains an entry with the key.

Warning

This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key’s class.

Parameters

key – The specified key.

Returns

True if this map contains an entry for the specified key,

False otherwise.

Return type

hazelcast.future.Future[bool]

contains_value(value)

Determines whether this map contains one or more keys for the specified value.

Parameters

value – The specified value.

Returns

True if this map contains an entry for the specified value,

False otherwise.

Return type

hazelcast.future.Future[bool]

entry_set()

Returns a List clone of the mappings contained in this map.

Warning

The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.

Returns

The list of key-value tuples in the map.

Return type

hazelcast.future.Future[list[tuple]]

get(key)

Returns the value for the specified key, or None if this map does not contain this key.

Warning

This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key’s class.

Parameters

key – The specified key.

Returns

The value associated with the specified key.

Return type

hazelcast.future.Future[any]

is_empty()

Returns True if this map contains no key-value mappings.

Returns

True if this map contains no key-value mappings.

Return type

hazelcast.future.Future[bool]

key_set()

Returns the list of keys in the ReplicatedMap.

Warning

The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.

Returns

A list of the clone of the keys.

Return type

hazelcast.future.Future[list]

put(key, value, ttl=0)

Associates the specified value with the specified key in this map.

If the map previously contained a mapping for the key, the old value is replaced by the specified value. If ttl is provided, entry will expire and get evicted after the ttl.

Parameters
  • key – The specified key.

  • value – The value to associate with the key.

  • ttl (int) – Maximum time in seconds for this entry to stay, if not provided, the value configured on server side configuration will be used.

Returns

Previous value associated with key or None

if there was no mapping for key.

Return type

hazelcast.future.Future[any]

put_all(source)

Copies all of the mappings from the specified map to this map.

No atomicity guarantees are given. In the case of a failure, some of the key-value tuples may get written, while others are not.

Parameters

source (dict) – Map which includes mappings to be stored in this map.

Returns

Return type

hazelcast.future.Future[None]

remove(key)

Removes the mapping for a key from this map if it is present.

The map will not contain a mapping for the specified key once the call returns.

Warning

This method uses __hash__ and __eq__ methods of binary form of the key, not the actual implementations of __hash__ and __eq__ defined in key’s class.

Parameters

key – Key of the mapping to be deleted.

Returns

The previous value associated with key, or None

if there was no mapping for key.

Return type

hazelcast.future.Future[any]

remove_entry_listener(registration_id)

Removes the specified entry listener.

Returns silently if there is no such listener added before.

Parameters

registration_id (str) – Id of registered listener.

Returns

True if registration is removed, False otherwise.

Return type

hazelcast.future.Future[bool]

size()

Returns the number of entries in this multimap.

Returns

Number of entries in this multimap.

Return type

hazelcast.future.Future[int]

values()

Returns the list of values in the map.

Warning

The returned list is NOT backed by the map, so changes to the map are NOT reflected in the list, and vice-versa.

Returns

The list of values in the map.

Return type

hazelcast.future.Future[list]