|
Cluster Storage plugin. It provides the user with a mechanism for permanent data storage using the Cluster scope. This plugin creates a special variable in cluster scope that correctly identifies the coldbox app.
Important : This plugin only works under Railo CFML Engine and its cluster scope
Set a new permanent variable.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The name of the variable. |
| value | any | Yes | --- | The value to set in the variable. |
// Prepare data, can be simple or complex userData = { name = "Luis Majano", created = now(), nicknames = ["Captain Awesome", "Pio"], awesomeLevel = "high" }; getPlugin("ClusterStorage").setVar("userData", userData);
Get a new permanent variable. If the variable does not exist. The method returns blank unless using the default return argument.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
| default | any | No | The default value to set. If not used, a blank is returned. |
// No default var userData = getPlugin("ClusterStorage").getVar("userData"); // With Default var data= getPlugin("ClusterStorage").getVar("userData", structNew() );
remove the entire storage from scope
// Remove the entire cluster storage getPlugin("ClusterStorage").removeStorage();
Checks wether the permanent variable exists.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
if ( getPlugin("ClusterStorage").exists("userData") ){ // use the data }
Clear the entire coldbox cluster storage
getPlugin("ClusterStorage").clearAll();
Tries to delete a permanent cluster variable. Returns True if deleted.
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
getPlugin("ClusterStorage").deleteVar("userData");
Get the entire storage scope structure
var clusterStore = getPlugin("ClusterStorage").getStorage();