Skip to content

Map

Purpose

Provides cluster wide map methods.

Methods

Binding name: p6.map


with

New Feature

Since 6.9.3

Execute the supplied critical section to a named cluster wide map. The map will be automatically created (if it does not exist) and locked within the specified acquire timeout.

Syntax

boolean p6.map.with(String mapName, long acquireTimeoutMillis, Closure<Void> criticalSection)

The Closure accepts the map as parameter

Info

The map is always locked which guarantees exclusive access to the map while in the critical section (Closure)

If lock acquisition fails this method will return false.

Example
def acquiredMap = p6.map.with('myMap', 1000) { map ->
    // The lock will be released once this code block completes
    map.put('key', 'value')
}
// Failure to acquire the lock within the given timeout
if(!acquiredMap){
    p6.log.debug 'Failed to acquire Map for exclusive access'
}

with (persistent)

New Feature

Since 6.10.12

Execute the supplied critical section to a named cluster wide persistent map. The map will be automatically created (if it does not exist) and locked within the specified acquire timeout.

Syntax

boolean p6.map.persistent.with(String mapName, long acquireTimeoutMillis, Closure<Void> criticalSection)

The Closure accepts the map as parameter

Info

The map is always locked which guarantees exclusive access to the map while in the critical section (Closure)

If lock acquisition fails this method will return false.

Example
def acquiredMap = p6.map.persistent.with('myMap', 1000) { map ->
    // The lock will be released once this code block completes
    map.put('key', 'value')
}
// Failure to acquire the lock within the given timeout
if(!acquiredMap){
    p6.log.debug 'Failed to acquire Map for exclusive access'
}

destroy

New Feature

Since 6.9.3

Destroy the named cluster wide map and release any associated resources.

Syntax

void p6.map.destroy(String mapName)
Example
p6.map.destroy 'myMap'

destroy (persistent)

New Feature

Since 6.10.12

Destroy the persistent named cluster wide map and release any associated resources.

Syntax

void p6.map.persistent.destroy(String mapName)
Example
p6.map.persistent.destroy 'myMap'