Local maps can be used to share data safely in a single Vert.x instance.
The map only allows immutable keys and values in the map, OR certain mutable objects such as Buffer instances which will be copied when they are added to the map.
This ensures there is no shared access to mutable state from different threads (e.g. different event loops) in the Vert.x instance, and means you don't have to protect access to that state using synchronization or locks.
Your own objects can be marked as immutable by implementing the io.vertx.core.shareddata.Shareable
interface.
Since the version 3.4, this class extends the interface. However some methods are only accessible in Java.
Anything
Object
LocalMap
Basic
Identifiable
Object
Anything
no subtypes hierarchy
Initializer |
LocalMap(LocalMap<out Object,out Object> unknown) |
Inherited Attributes |
Attributes inherited from: Object hash , string |
Methods | |
clear | shared default void clear() Clear all entries in the map |
close | shared default void close() Close and release the map |
containsKey | shared default Boolean containsKey(Object? key) Returns Parameters:
|
containsValue | shared default Boolean containsValue(Object? value) Returns @{code true} if this map maps one or more keys to the specified value. Parameters:
|
get | shared default V get(Object? key) Get a value from the map Parameters:
|
getOrDefault | shared default V getOrDefault(Object? key, V defaultValue) Returns the value to which the specified key is mapped, or
Parameters:
|
isEmpty | shared default Boolean isEmpty() |
put | shared default V put(K key, V value) Put an entry in the map Parameters:
|
putIfAbsent | shared default V putIfAbsent(K key, V value) Put the entry only if there is no existing entry for that key Parameters:
|
remove | shared default V remove(Object? key) Remove an entry from the map Parameters:
|
removeIfPresent | shared default Boolean removeIfPresent(K key, V value) Remove the entry only if there is an entry with the specified key and value. This method is the poyglot version of remove. Parameters:
|
replace | shared default V replace(K key, V value) Replace the entry only if there is an existing entry with the key Parameters:
|
replaceIfPresent | shared default Boolean replaceIfPresent(K key, V oldValue, V newValue) Replace the entry only if there is an existing entry with the specified key and value. This method is the polyglot version of replace. Parameters:
|
size | shared default Integer size() Get the size of the map |
Inherited Methods |
Methods inherited from: Object equals |