Cache System Task
CACHE_TASK is a System Task that provides read and write functionality to the in-memory cache.
Store any data from a workflow into the cache and refresh it after a specified duration. Also search the cache for specified data.
Example store data
This example workflow authenticates and runs a GET call to an external endpoint. Then the data is stored into the cache with a duration of 1 week, after which the workflow will be called again to refresh the data.
[
{
"description": "Get list of schools from CCGI. This WF can be called to refresh the school list cache",
"name": "CCGI-schoolList-cache-refreshWF",
"version": 1,
"inputParameters": [],
"tasks": [
{
"description": "Generate HMAC auth header for CCGI based on URLx`",
"name": "value-mapper",
"taskReferenceName": "ccgi-auth-schoollist",
"type": "VALUE_MAPPER",
"inputParameters": {
"sources": {
"header": null
},
"functions": [
{
"source": "header",
"funcName": "StringUtils.ccgiSchoollistAuthHeader",
"funcArgs": ["${ETRANSCRIPT_CCGI_SECRET}", "${ETRANSCRIPT_CCGI_SCHOOLLIST_URL}"]
}
]
}
}
,{
"description": "Call CCGI to get list of schools",
"name": "http-generic",
"taskReferenceName": "get-schoolList",
"type": "HTTP",
"inputParameters": {
"http_request": {
"method": "GET",
"headers": {
"Authorization": "${ccgi-auth-schoollist.output.header}"
},
"uri": "${ETRANSCRIPT_CCGI_SCHOOLLIST_URL}"
}
}
}
,{
"description": "Store list of schools in cache. Set cache key and refresh properties.",
"name": "cache-task",
"taskReferenceName": "cache-schoolList",
"type": "CACHE_TASK",
"inputParameters": {
"cache-key": "ccgi-schoolList",
"cache-value" : "${get-schoolList.output.response.body}",
"cache-refresh" : {
"workflow-name": "${workflow.workflowType}",
"workflow-version": 1,
"duration-hours" : 168
}
}
}
],
"schemaVersion": 2,
"outputParameters" : {
"schoolList" : "${get-schoolList.output.response.body}"
}
}
]
All configuration is in the workflow and the CACHE_TASK definition.
Example search cache
With the above data stored into the cache, the below will search the cache.
[
{
"description": "Search list of supported schools by CCGI",
"name": "CCGI-schoolList-searchWF",
"version": 1,
"inputParameters": [
"search"
],
"tasks": [
{
"description": "Find school in cache, returns school or null",
"name": "cache-task",
"taskReferenceName": "search-for-school",
"type": "CACHE_TASK",
"inputParameters": {
"cache-key": "ccgi-schoolList",
"search-key" : "cdscode",
"search-value" : "${workflow.input.search.cdscode}"
}
}
],
"schemaVersion": 2,
"outputParameters" : {
"school" : "${search-for-school.output.results}"
}
}
]
The below shows a call to the above search task and specifies searching the cache for a node named cdscode
and specified value.
{
"name": "CCGI-schoolList-searchWF",
"version": 1,
"input" : {
"search" : {
"cdscode" : "34674393431012"
}
},
"schemaVersion": 2
}