Writing to a Time Cache Definition
  • 17 May 2023
  • 3 Minutes to read
  • Dark
    Light

Writing to a Time Cache Definition

  • Dark
    Light

Article Summary

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. 

Additional Information
The following document involves the use of Cache Definitions. For more information on Cache Definitions, see the Cache Definitions document.

Example

The following document demonstrates how to store and retrieve an email address using a TimeCacheDefinition. 

  1. From the DecisionsStudio, navigate to System > Administration > Cache, select ADD, then MemoryCacheDefinition.
  2. From the MemoryCacheDefinition window, provide a Configuration Name, then click SAVE. 
  3. 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.
  4. 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 Name 
    Note that the Target Cache Config Name represents the Cache that the TimeCacheDefinition will be applied to. 


  5. Scroll to Check On Interval Span and establish the desired value; for this example Minute. Then, set the Interval value; for this example 5 Minutes, then click SAVE. 

    Additional Information on Intervals 
    These values are used to determine how long data from the associated Cache is stored in the Cache. 


  6. Navigate to a Designer Project, then select CREATE FLOW and CREATE a new Flow

  7. From the Flow Designer, attach a Create Data step from the FAVORITE STEPS category to the Start step. 

  8. From the Properties tab of the Create Data step, under DATA > Data to Create, select SHOW EDITOR.


  9. 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.


  10. Back in the Flow Designer, navigate to Toolbox > SYSTEM > CACHING, and attach a Put In Cache step to the Create Data step. 

  11. 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 Properties
    The Storage Instance Name and Key values are used to both store and retrieve the cached data. 


  12. 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. 


  13. Save the Flow, then if desired, close via X. 



Debug

  1. From the Flow Designer, select the Debug link from the top Action bar. 
  2. After the Flow runs, select Put In Cache 1 > Execution 1 > View Input/Output Data
    Debug Results 
    Note 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.


Was this article helpful?

What's Next