TransactionalMap¶
- class TransactionalMap(name, transaction, context)[source]¶
Bases:
TransactionalProxy
,Generic
[KeyType
,ValueType
]Transactional implementation of
Map
.- contains_key(key: KeyType) bool [source]¶
Transactional implementation of
Map.contains_key(key)
- Parameters:
key – The specified key.
- Returns:
True
if this map contains an entry for the specified key,False
otherwise.
- get(key: KeyType) ValueType | None [source]¶
Transactional implementation of
Map.get(key)
- Parameters:
key – The specified key.
- Returns:
The value for the specified key.
- get_for_update(key: KeyType) ValueType | None [source]¶
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 – The specified key.
- Returns:
The value for the specified key.
See also
- size() int [source]¶
Transactional implementation of
Map.size()
- Returns:
Number of entries in this map.
- is_empty() bool [source]¶
Transactional implementation of
Map.is_empty()
- Returns:
True
if this map contains no key-value mappings,False
otherwise.
- put(key: KeyType, value: ValueType, ttl: float = None) ValueType | None [source]¶
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 – The specified key.
value – The value to associate with the key.
ttl – Maximum time in seconds for this entry to stay.
- Returns:
Previous value associated with key or
None
if there was no mapping for key.
- put_if_absent(key: KeyType, value: ValueType) ValueType | None [source]¶
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 – Key of the entry.
value – Value of the entry.
- Returns:
Old value of the entry.
- set(key: KeyType, value: ValueType) None [source]¶
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 – Key of the entry.
value – Value of the entry.
- replace(key: KeyType, value: ValueType) ValueType | None [source]¶
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 – The specified key.
value – The value to replace the previous value.
- Returns:
Previous value associated with key, or
None
if there was no mapping for key.
- replace_if_same(key: KeyType, old_value: ValueType, new_value: ValueType) bool [source]¶
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 – The specified key.
old_value – Replace the key value if it is the old value.
new_value – The new value to replace the old value.
- Returns:
True
if the value was replaced,False
otherwise.
- remove(key: KeyType) ValueType | None [source]¶
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 – Key of the mapping to be deleted.
- Returns:
The previous value associated with key, or
None
if there was no mapping for key.
- remove_if_same(key: KeyType, value: ValueType) bool [source]¶
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 – The specified key.
value – Remove the key if it has this value.
- Returns:
True
if the value was removed,False
otherwise.
- delete(key: KeyType) None [source]¶
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 – Key of the mapping to be deleted.
- key_set(predicate: Predicate = None) List[KeyType] [source]¶
Transactional implementation of
Map.key_set(predicate)
- Parameters:
predicate – Predicate to filter the entries.
- Returns:
A list of the clone of the keys.
- values(predicate: Predicate = None) List[ValueType] [source]¶
Transactional implementation of
Map.values(predicate)
- Parameters:
predicate – Predicate to filter the entries.
- Returns:
A list of clone of the values contained in this map.