Plugins:ClusterStorage
|
Exploring the ClusterStorage Plugin
Overview
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
setVar
Set a new permanent variable.
Returns
- This function returns void
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The name of the variable. |
| value | any | Yes | --- | The value to set in the variable. |
Examples
// Prepare data, can be simple or complex userData = { name = "Luis Majano", created = now(), nicknames = ["Captain Awesome", "Pio"], awesomeLevel = "high" }; getPlugin("ClusterStorage").setVar("userData", userData);
getVar
Get a new permanent variable. If the variable does not exist. The method returns blank unless using the default return argument.
Returns
- This function returns any
Arguments
| 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. |
Examples
// No default var userData = getPlugin("ClusterStorage").getVar("userData"); // With Default var data= getPlugin("ClusterStorage").getVar("userData", structNew() );
removeStorage
remove the entire storage from scope
Returns
- This function returns void
Examples
// Remove the entire cluster storage getPlugin("ClusterStorage").removeStorage();
exists
Checks wether the permanent variable exists.
Returns
- This function returns boolean
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
Examples
if ( getPlugin("ClusterStorage").exists("userData") ){ // use the data }
clearAll
Clear the entire coldbox cluster storage
Returns
- This function returns void
Examples
getPlugin("ClusterStorage").clearAll();
deleteVar
Tries to delete a permanent cluster variable. Returns True if deleted.
Returns
- This function returns boolean
Arguments
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| name | string | Yes | --- | The variable name to retrieve. |
Examples
getPlugin("ClusterStorage").deleteVar("userData");
getStorage
Get the entire storage scope structure
Returns
- This function returns struct
Examples
var clusterStore = getPlugin("ClusterStorage").getStorage();

SideBar
User Login 




Comments (