Cache StepsLast Updated: 07/22/2016 Introduced in Verision: 3.2 |
This tutorial demonstrates how to use Cache Steps in Decisions. With Cache Steps we can store and retrieve some Data values in memory for defined time. In Decisions we are able to define different types of Cache. When we are trying to store some value in Cache, we need to define an Instance of the Cache, its type and a Key to access current Value.
Note: [List] Add Item and [List] Get From Cache steps are explained in the following tutorial: http://decdocs3x.wpengine.com/cache-fetch-flow-behavior/
Example:
In this example we are going to use Cache steps to store the values of the selected row on the Report to use this values on the Form.
For this example we created a simple Report on the Northwind Customers database table.
Next, we are going to create a Flow for the Selected Row. In the Designer Folder we click Create Flow on the Folder Actions Panel.
In the resulting window we Name the Flow, select Report Selected Row Handler Flow Behavior, and click Create to proceed to the Flow Designer.
In the Flow Designer we add Put In Cache step from the All Steps [Catalog] > Data > Cache category.
Then, we configure data for this Step as following… Define Constant Cache Instance Name (this can be any name that we want to associate with this cache). Constant Cache Type Name (this can be either default decisions cache or our custom cache that is defined in the System > Administration > Cache Folder in the Portal).
Constant Key for this Value. Finally, we Select Value that we want to store from the Selected Row Fields. In this step we are going to store CustomerId field that will be accessible by ID key in this Cache Instance.
Next, we add another Put In Cache step from the All Steps [Catalog] > Data > Cache category.
We configure this step in the similar manner we configured previous Put In Cache step except this time we define different Key and Value. As a result, we save different Value with different Key in the same Cache.
Then, we add another Put In Cache step from the All Steps [Catalog] > Data > Cache category.
Again, we configure this step to store our desirable Value with the Key that we can use to access this Value.
Finally, we connect steps in our Flow as following. This completes our Cache Flow. We can save the Flow and close Flow Designer.
Then, we are going to create a Flow that will be using Cached values. In the Designer Folder we click Create Flow on the Folder Actions Panel.
In the resulting window we Name the Flow and click Create to proceed to the Flow Designer.
In the Flow Designer we add Get From Cache Step from the All Steps [Catalog] > Data > Cache category. With this step we can access our cached values.
We configure this step as following… We define Constant Cache Instance and Type that we created in the first Flow in this tutorial. Then, we define Constant Key of the Value that we need to retrieve from the Cache (in this case it is ID which is a Key for CustomerId value in SelectedCustomer instance of the Default.MemoryCache). Also, we Rename the Result Value output.
Then, we add another Get From Cache Step from the All Steps [Catalog] > Data > Cache category.
We configure this step to get Contact Name Value from the Instance of the Cache that we defined for this tutorial.
Next, we add and configure another Get From Cache Step from the All Steps [Catalog] > Data > Cache category. With this step we are going to get Company Name value from our Cache.
Then, we add a Show Form step from Favorite Steps category.
In the resulting window we Name the Form and click Create to proceed to the Form Designer.
On this Form we are going to display our Values from Cache. When we finished Form design we can save the Form and close Form Designer.
Back in the Flow Designer we connect the outcome from the Form Step to the End Step. This completes our Display Flow. We save the Flow and close Flow Designer.
Next, we are going to create a Page to display Report and Form. In the Designer Folder we click Create Report/Page > Create Page/Dashboard option on the Folder Actions Panel.
In the Page Designer we are going to display our Report with Report Viewer component. We are going to Edit Behavior of the Report Viewer.
Using Selected Row Flow picker we select our Flow that stores Values in Cache.
Then, with Flow Run Part component we are going to add our Display Flow to the Page. This completes our Page Design. We save our Page and close Page Designer.
In the Designer Folder we add our Page as a view for the Folder.
When the Page is displayed, our Form displays values from the first row in the Report.
Then, we select different Row on the Report and click Refresh on the Form.
Our Form reloads and displays new cached values from the current selected row on the Report.
Cache Steps that are not covered in this tutorial:
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.