Sometimes it makes sense to allow different verticles instances to share data in a safe way. Vert.x allows simple Map and Set data structures to be shared between verticles.
There is a caveat: To prevent issues due to mutable data, vert.x only allows simple immutable types such as number, boolean and string or Buffer to be used in shared data. With a Buffer, it is automatically copied when retrieved from the shared data, so different verticle instances never see the same object instance.
Methods
-
<static> getMap(name) → {Object}
-
Return a
Map
with the specificname
. All invocations of this method with the same value ofname
are guaranteed to return the sameMap
instance.Parameters:
Name Type Description name
string The name of the map - Source:
Returns:
The shared data map- Type
- Object
-
<static> getSet(name) → {Array}
-
Return a
Set
with the specificname
. All invocations of this method with the same value ofname
are guaranteed to return the sameSet
instance.Parameters:
Name Type Description name
string The name of the set - Source:
Returns:
The shared data set- Type
- Array