# 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:

  - Cluster wide maps which can be accessed from any node of the cluster
  - Cluster wide locks which can be used to give exclusive access to resources across the cluster
  - Cluster wide counters used to maintain counts consistently across the cluster
  - Local maps for sharing data safely in the same Vert.x instance

  Please see the documentation for more information.

  Source:
    - shared_data.js, line 43

### Methods

#### 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:
    - shared_data.js, line 56

#### getCounter(name, resultHandler)

  Get a cluster wide 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:
    - shared_data.js, line 118

#### getLocalMap(name) → {LocalMap}

  Return a `LocalMap` with the specific `name`.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `name` | string | the name of the map

  Source:
    - shared_data.js, line 138

  ##### Returns:

  the msp
  Type
    LocalMap

#### getLock(name, resultHandler)

  Get a cluster wide 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:
    - shared_data.js, line 76

#### 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:
    - shared_data.js, line 98