SharedMap
Persistent data sharing between tasks.
Note:
- Creates a copy of passed data and stores it independently of job creation / deletion.
- Stored data is not erased when the task that created it ends.
- The SharedMap object supports concurrent access between tasks.
SharedMap class
class SharedMap {
constructor SharedMap( String uniquename );
bool store( string key, {JSON Object} );
{JSON Object} load( string key );
bool contains( string key ) ;
bool clear( string key );
Array keys();
Array dump();
}
.store
Store 'data' datas in a SharedMap object 'dictionnary_1)
var x = new SharedMap('dictionnary_1');
x.store( 'key1', data );
'data' is a JSON object type.
.load
Get data contents from a SharedMap engine
.contains
Check if key is present in a SharedMap objest
.clear
Remove the key from SharedMap object
.keys
Display keys from SharedMap engine
- Example :
First task :
var x = new SharedMap('dictionnary_1');
var data = { 'param1' : 3, 'param2' : 0 };
x.store( 'key1', data );
Second task :
var x = new SharedMap('dictionnary_1');
if( x.contains('key1') ) {
var y = x.load('key1');
print( y.param1 );
}
Retrieve all stored keys :
var x = new SharedMap('dictionnary_1');
var data = { 'param1' : 3, 'param2' : 0 };
x.store( 'key1', data );
x.store( 'key2', data );
var keys = x.keys();
// keys = ["key1","key2"]
.dump()
Returns an array of object with all the elements stored in the SharedMap. Each returned object of the array has two attributes :
- key : the key name used in the SharedMap
- value : a string, representing the content.
Last update: March 12, 2023