Class: SharedData

vertx-js/shared_data~ SharedData

new SharedData()

Shared data allows you to share data safely between different parts of your application in a safe way.

Shared data provides:

  • synchronous shared maps (local)
  • asynchronous maps (local or cluster-wide)
  • asynchronous locks (local or cluster-wide)
  • asynchronous counters (local or cluster-wide)

WARNING: In clustered mode, asynchronous maps/locks/counters rely on distributed data structures provided by the cluster manager. Beware that the latency relative to asynchronous maps/locks/counters operations can be much higher in clustered than in local mode.

Please see the documentation for more information.
Source:

Methods

getAsyncMap(name, resultHandler)

Get the AsyncMap with the specified name. When clustered, the map is accessible to all nodes in the cluster and data put into the map from any node is visible to to any other node.

WARNING: In clustered mode, asynchronous shared maps rely on distributed data structures provided by the cluster manager. Beware that the latency relative to asynchronous shared maps operations can be much higher in clustered than in local mode.

Parameters:
Name Type Description
name string the name of the map
resultHandler function the map will be returned asynchronously in this handler
Source:

getClusterWideMap(name, resultHandler)

Get the cluster wide map with the specified name. The map is accessible to all nodes in the cluster and data put into the map from any node is visible to to any other node.
Parameters:
Name Type Description
name string the name of the map
resultHandler function the map will be returned asynchronously in this handler
Source:

getCounter(name, resultHandler)

Get an asynchronous counter. The counter will be passed to the handler.
Parameters:
Name Type Description
name string the name of the counter.
resultHandler function the handler
Source:

getLocalMap(name) → {LocalMap}

Return a LocalMap with the specific name.
Parameters:
Name Type Description
name string the name of the map
Source:
Returns:
the msp
Type
LocalMap

getLock(name, resultHandler)

Get an asynchronous lock with the specified name. The lock will be passed to the handler when it is available.
Parameters:
Name Type Description
name string the name of the lock
resultHandler function the handler
Source:

getLockWithTimeout(name, timeout, resultHandler)

Like SharedData#getLock but specifying a timeout. If the lock is not obtained within the timeout a failure will be sent to the handler
Parameters:
Name Type Description
name string the name of the lock
timeout number the timeout in ms
resultHandler function the handler
Source: