- 14 Aug 2024
- 3 Minutes to read
- Print
- DarkLight
Writing to a Time Cache Definition
- Updated on 14 Aug 2024
- 3 Minutes to read
- Print
- DarkLight
Overview
To limit the amount of data saved to a Cache or to establish a custom expiration time for a cached Value, users may establish a Time Cache Definition. Time Cache Definitions can be used in conjunction with any other Type of Cache Definition to adjust the time the cached data exists within the Cache. In addition, the Time Cache Definitions can be used to Cache the Output of a step and store and retrieve it outside a Flow.
Example
The following document demonstrates how to store and retrieve an email address using a TimeCacheDefinition.
- From the DecisionsStudio, navigate to System > Administration > Cache, select ADD, then MemoryCacheDefinition.
- From the MemoryCacheDefinition window, provide a Configuration Name, then click SAVE.
- From the same Cache Folder, select ADD once more, then select TimeCacheDefinition.Once a time cache has been created using a cache definition, making any changes to that cache definition will not change any already existing time caches; only new instances will use updated cache definitions.
- From the TimeCacheDefinition window, provide the desired Configuration Name. Then under TIME CACHE DEFINITION INFO, select the previously created MemoryCacheDefinition from the Target Cache Config Name dropdown.Additional Information on Target Cache Config NameNote that the Target Cache Config Name represents the Cache that the TimeCacheDefinition will be applied to.
Scroll to Check On Interval Span and establish the desired value; for this example 1 Minute. Then, set the Interval value; for this example 5 Minutes, then click SAVE.
Additional Information on IntervalsThese values are used to determine how long data from the associated Cache is stored in the Cache.Navigate to a Designer Project, then select CREATE FLOW and CREATE a new Flow.
From the Flow Designer, attach a Create Data step from the FAVORITE STEPS category to the Start step.
From the Properties tab of the Create Data step, under DATA > Data to Create, select SHOW EDITOR.
From the Data to Create window, provide a NAME, select String [Text] from the TYPE dropdown, INPUT the desired Email. Save then close the window via X.
Back in the Flow Designer, navigate to Toolbox > SYSTEM > CACHING, and attach a Put In Cache step to the Create Data step.
From the Put In Cache step's Properties, Constant map the Cache Type Name that corresponds to the Name of the TimeCacheDefinition. Constant map the desired Cache Instance Name and Key, Then Select From Flow map the Output of the Create Data step to Value.
Additional Information on Put In Cache PropertiesThe Storage Instance Name and Key values are used to both store and retrieve the cached data.From the same CACHING category in the Toolbox tab, attach a Get From Cache step to the Done path of the Put In Cache step. From the newly added step's Properties, Constant map the sane Cache Instance Name, Cache Type Name, and Key values, that were used in the Put In Cache step's Properties. Then connect the Result path to the End step.
Save the Flow, then if desired, close via X.
Debug
- From the Flow Designer, select the Debug link from the top Action bar.
- After the Flow runs, select Put In Cache 1 > Execution 1 > View Input/Output Data. Debug ResultsNote that as long as the Value has not expired that the resulting Output Data will reflect the Value stored in the TimeCacheDefinition. This Value will display in its original String form due to its association with the MemoryCacheDefinition.
How Time Cache Data is Stored
By associating a TimeCacheDefinition with a MemoryCacheDefinition as a Target Cache Config Name, when data is stored in the TimeCache its Value is actually stored in the affiliate MemoryCache.
This data's record can be seen by navigating to System > Administration > System Tools > Event Viewer, under the Cache Size tab in the format of [TargetCacheConfigName]||[InstanceNameAffiliatedWithTimeCache]. This record is displayed alongside a Count of how many items exist in that Instance.