TransactionalMap

class TransactionalMap(name, transaction)

Bases: hazelcast.proxy.base.TransactionalProxy

Transactional implementation of Map.

contains_key(key)

Transactional implementation of Map.contains_key(key)

Parameters

key – (object), the specified key.

Returns

(bool), true if this map contains an entry for the specified key, false otherwise.

get(key)

Transactional implementation of Map.get(key)

Parameters

key – (object), the specified key.

Returns

(object), the value for the specified key.

get_for_update(key)

Locks the key and then gets and returns the value to which the specified key is mapped. Lock will be released at the end of the transaction (either commit or rollback).

Parameters

key – (object), the specified key.

Returns

(object), the value for the specified key.

See also

Map.get(key)

size()

Transactional implementation of Map.size()

Returns

(int), number of entries in this map.

is_empty()

Transactional implementation of Map.is_empty()

Returns

(bool), true if this map contains no key-value mappings, false otherwise.

put(key, value, ttl=-1)

Transactional implementation of Map.put(key, value, ttl)

The object to be put will be accessible only in the current transaction context till the transaction is committed.

Parameters
  • key – (object), the specified key.

  • value – (object), the value to associate with the key.

  • ttl – (int), maximum time in seconds for this entry to stay (optional).

Returns

(object), previous value associated with key or None if there was no mapping for key.

put_if_absent(key, value)

Transactional implementation of Map.put_if_absent(key, value)

The object to be put will be accessible only in the current transaction context till the transaction is committed.

Parameters
  • key – (object), key of the entry.

  • value – (object), value of the entry.

  • ttl – (int), maximum time in seconds for this entry to stay in the map (optional).

Returns

(object), old value of the entry.

set(key, value)

Transactional implementation of Map.set(key, value)

The object to be set will be accessible only in the current transaction context till the transaction is committed.

Parameters
  • key – (object), key of the entry.

  • value – (object), value of the entry.

replace(key, value)

Transactional implementation of Map.replace(key, value)

The object to be replaced will be accessible only in the current transaction context till the transaction is committed.

Parameters
  • key – (object), the specified key.

  • value – (object), the value to replace the previous value.

Returns

(object), previous value associated with key, or None if there was no mapping for key.

replace_if_same(key, old_value, new_value)

Transactional implementation of Map.replace_if_same(key, old_value, new_value)

The object to be replaced will be accessible only in the current transaction context till the transaction is committed.

Parameters
  • key – (object), the specified key.

  • old_value – (object), replace the key value if it is the old value.

  • new_value – (object), the new value to replace the old value.

Returns

(bool), true if the value was replaced, false otherwise.

remove(key)

Transactional implementation of Map.remove(key)

The object to be removed will be removed from only the current transaction context until the transaction is committed.

Parameters

key – (object), key of the mapping to be deleted.

Returns

(object), the previous value associated with key, or None if there was no mapping for key.

remove_if_same(key, value)

Transactional implementation of Map.remove_if_same(key, value)

The object to be removed will be removed from only the current transaction context until the transaction is committed.

Parameters
  • key – (object), the specified key.

  • value – (object), remove the key if it has this value.

Returns

(bool), true if the value was removed, false otherwise.

delete(key)

Transactional implementation of Map.delete(key)

The object to be deleted will be removed from only the current transaction context until the transaction is committed.

Parameters

key – (object), key of the mapping to be deleted.

key_set(predicate=None)

Transactional implementation of Map.key_set(predicate)

Parameters

predicate – (Predicate), predicate to filter the entries (optional).

Returns

(Sequence), a list of the clone of the keys.

See also

Predicate for more info about predicates.

values(predicate=None)

Transactional implementation of Map.values(predicate)

Parameters

predicate – (Predicate), predicate to filter the entries (optional).

Returns

(Sequence), a list of clone of the values contained in this map.

See also

Predicate for more info about predicates.