Skip to content

Map

Purpose

Provides cluster wide map methods.

Methods

Binding name: p6.map


with

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){
    println 'Failed to acquire Map for exclusive access'
}

destroy

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')