- 17 May 2023
- 4 Minutes to read
- Print
- DarkLight
Cache Steps
- Updated on 17 May 2023
- 4 Minutes to read
- Print
- DarkLight
Overview
With Cache Steps, users can store and retrieve data values in memory for a defined time. In Decisions, there is the ability to define different types of Cache. While trying to store some value in Cache, define an Instance of the cache, cache type, and a key to access the current value.
Put in Cache
The following example demonstrates how to use the Put in Cache step to store and receive an email using a MemoryCacheDefinition.
- In the Decisions Studio, navigate to System > Administration > Cache and click ADD. Select MemoryCacheDefinition.
- From the MemoryCacheDefinition window, provide the desired Configuration Name and Description. Click SAVE.
- From a Designer Project, select CREATE FLOW from the Global Action Bar. Select Flow, name the Flow, and click CREATE.
- On the Toolbox panel, navigate to Toolbox > SYSTEM > CACHING and attach a Put In Cache step to the Start and End steps.
- On the Properties panel, enter "StoreEmailCache" in the Cache Instance Name field. Select the Unknown on Cache Type Name and select Constant and enter "AdminEmails".
- Enter "1" in the Key field and "admin@decisions" Value. Additional Info on KeyThe Key Input is used as an identifier for the Value being placed in the Cache. It is used to both organize the Value in the Cache and can be used to later locate and pull the Cache via additional steps.
- Click Save to save changes to the Flow. Click Debug from the top action bar. Click START DEBUGGING.
- After the Flow runs, select the Put In Cache step. Click Execution 1 and select View Input/Output Data to verify that the value was stored in the Cache.
Get From Cache
The following example demonstrates how to pull an email address from an email cache via a Flow.
- In a Designer Project, click CREATE FLOW. Select Flow, name the Flow, and click CREATE.
- In the Flow Designer, attach a Get From Cache step from Toolbox > SYSTEM > CACHING to the Start and End steps.
- From the Properties tab of the Get From Cache step, Constant map the corresponding Cache Instance Name,Cache Type Name, and Key that were used to place the Value in the Cache.
- Click Save to save changes to the Flow. Click the Debug on the top action bar, then click START DEBUGGING.
- After the Flow runs, click Get From Cache > Execution 1 > View Input/Output to verify that the retrieved email matches the one that was added previously to the Cache.
Adding Multiple Items to Cache
The following example demonstrates how to add multiple items to a Cache compiling Admin Emails, via a Flow.
- In a Designer Project, click CREATE FLOW. Select Flow, name the Flow, and click CREATE.
- From the Toolbox panel, attach a Create Data step from the FAVORITE STEPS category to the Start step.
- From the Properties tab of the Create Data step select SHOW EDITOR.
- From the Data to Create window, provide a NAME and select the corresponding TYPE from the drop-down menu (in this case String). Then, check the IS LIST box.
- Set INPUT to Constant, then map the desired Emails. Click DONE then Save and close the window.
- From FAVORITE STEPS, attach a Run Sub Flow step to the Create Data step. Then, navigate to the Run Sub Flow steps Properties and select the PICK OR CREATE FLOW button; CREATE a new Flow.
- From the Flow Designer of the new Sub Flow, select SETUP INPUT DATA and then DEFINE under Define Input Data.
- From the Input Data window, provide a Name, select the corresponding TYPE (in this example, String), and check IS LIST. Then, save and close the window.
- From Toolbox > FLOW MANAGEMENT > ITERATION, attach a ForEach Step step to the Done path of the Start step. From the ForEach Step's Properties tab, Select From Flow map the Input Data. Then, under DATA > Type, select the corresponding DataType.
- Under Toolbox > SYSTEM > CACHING, attach a [List] Add Item step to the Next path of the ForEach Step. From the Properties of the Add Item step under CACHE SETUP, provide a Cache Instance Name and select the desired Cache Type Name.
- Under INPUTS, Constant map the desired Key value. Then, Select From Flow map Item to Value. Utilizing the same Key should allow the ability to recover all the added Values at once.
Connect the Done path of the [List] Add Item step to the ForEach Step, then connect the ForEach Step's Done path to the End step.
The ForEach Step is used to split the input List of Emails into individual items, then send each item to the [List] Add Item step to be added to the Cache.Save the changes to the Sub Flow and close the Sub Flow.
From the Parent Flow, select the Sub Flow step to navigate to its Properties tab and map the Output of the Create Data step, to the Email List Input of the Sub Flow.
Connect the Done path of the Sub Flow to the End step. Then, save the Flow.
Click Debug from the top action bar. Once the Flow runs successfully, close the Debugger.
Open an additional Flow Designer instance. From Toolbox > System > Caching, attach a [List] Get From Cache step to the Start step. Then, connect the Result path to the End path.
From the Properties tab of the [List] Get From Cache step, Constant map the respective Cache Instance Name, select the Cache Type Name, and map the corresponding Key input.
Click Save to save changes to the Flow. Then, click Debug from the top action bar.
Once the Flow runs, select [List] Get From Cache, click Execution 1, and select View Input/Output Data to view the Values added to Cache in List format.
Additional Cache Steps
The following table details additional Cache steps that are not covered in the previous tutorial.
Cache Step | Description |
---|---|
Clear Cache | Clear desired Instance in Cache (in this tutorial it would be SelectedCustomer instance of the Default.MemoryCache) |
Key Exist In Cache | check if the Instance of the Cache contains the Key (in this tutorial we had ID, CONTACTNAME, and COMPANYNAME keys) |
Put In Cache [generated key] | With this step, we can put the Value in our Cache and the step generates and outputs a Key to access this value. |
Remove Key From Cache | Removes the Value from our Cache instance by Key. |