Caching Data

◷ Reading Time: 3 minutes

cacheSet

Sets a value to a cache based on scope and key with a specific expiry time.

 cacheSet (scope, key, value, expiry)
  • Scope: Define scope name with reference to the cache data. (Mandatory)
  • Key: Cache Key is an identifier for your cache data. (Mandatory)
  • Value: Cache value which needs to store in the cache memory. (Mandatory)
  • Expiry: The expiry is optional, or it can be an integer value in minutes, or a timespan value. (Optional)
Example: cacheSet ("MyProjectScope", "CacheKey", [10,22,25,98], "never")
Result: Store the data array in a cache memory that scope is "MyProjectScope" with identifier "CacheKey" and never expire.
Example: cacheSet ("MyProjectScope", "CacheKey", LookupTable, 360)
Result: Store the value in the Lookuptable parameter in the cache memory scope which is "MyProjectScope" with identifier "CacheKey" and expire after 360 minutes.

cacheRemove

Remove a cache entry based on scope and key.

 cacheRemove (scope, key)
  • Scope: Scope name reference to the cache. (Mandatory)
  • Key: Cache Key is an identifier for your cache data. (Mandatory)
Example: cacheRemove ("MyProjectScope", "CacheKey")
Result: Remove the cache memory which related to the "MyProjectScope" and "CacheKey"

cacheRead

Returns the value of a cache based on scope and key, if does not exist it will return null.

 cacheRead (scope, key)
  • Scope: Scope name reference to the cache. (Mandatory)
  • Key: Cache Key is an identifier for your cache data. (Mandatory)
Example: cacheRead("MyProjectScope" , "CacheKey")
Result: Returns the value of the "CacheKey" as [10,22,25,98]

cacheExists

Checks existence of the cache entry based on scope and key and returns a Boolean value.

 cacheExists (scope, key)
  • Scope: Scope name reference to the cache. (Mandatory)
  • Key: Cache Key is an identifier for your cache data. (Mandatory)
Example: cacheExists("MyProjectScope" , "CacheKey")
Result: True

cacheClear

Clear all the cache entries for a specific scope. If scope is not specified, all the cache for the running process will be cleared.

 cacheClear (scope)
  • Scope: Scope name reference to the cache. (Mandatory)
Example: cacheClear("MyProjectScope" )
Return: Delete all the cache entries for "MyProjectScope"

cacheList

Lists all the cache entry for the running process.

 cacheList ()

Example: cacheList()
Return: Returns a list of cache data in the memory.
[
    {
        "Scope" : "MyProjectScope",
        "Key" : {"CacheKey"},
        "Value" : "[10,22,25,98]"
    }
]
Updated on October 26, 2023

Was this article helpful?

Related Articles