Constellation datapage caching and invalidation using messaging service (web socket)
Table of Contents
- Overview
- Component supports caching (OOTB)
- Cache invalidation
- Invalidate cache from server
- Invalidate cache from client
- DSS setting for caching: Server
- Caching for Custom DX Component
Overview
The architecture aims to optimize data page usage and leverage browser memory to enhance performance. Here are the key points:
- When data page results are downloaded to the client, they are pushed to an in-memory cache.
- Subsequent calls retrieve results directly from the cache, improving response time.
- Data pages marked as “Reload once per interaction” are not cached to ensure fresh data for each interaction.
Component supports caching (OOTB)
Table/listviews are bound to cache, once results fetched from server, results will be cached for subsequent use.
Cache invalidation
Do follow below steps to invalidate the client and server cache.
Trigger points
Trigger points are not handled OOTB, Application developer has to implement this logic.
It can be done in below ways:
- Defining declare trigger on class
- Bulk process
- Post processing of action/flow action.
Etc.,
Invalidate cache from server
- Remove one result of datapage, invalidate cache by calling page-remove.
OR
- Remove all result sets of the data page, call pzDeleteAllInstancesOfDeclarativePage RUF.
Example:
@DeclarePages.pzDeleteAllInstancesOfDeclarativePage(tools, "<datapage name>")
Example activity:
Invalidate cache from client
Invalidation happens through messaging service call (web socket), do follow below steps:
- Call activity pxC11NPublishDatapageUpdate and pass datapage name as parameter
- Activity can be called from declare triggers or standalone as one of the step logic execution.
Overall:
DSS setting for caching: Server
There are few settings which help to control the cache size and where to persist cache (node vs database).
- Cache size
Update/create dss setting “constellation/readOnlyDataPagesCacheSize”, default value is 200000L, indicates number of datapages entries.
- Control cache persist strategy
Update/create dss setting “constellation/readOnlyDataPagesCacheStrategy”, default value is node and in order to change to DB mention values as DB.
Caching for Custom DX Component
Use below PCore api to take advantage of caching:
To listen for updates:
const callbackFn = () => {};
PCore.getDataPageUtils().subscribeToUpdate("<datapage name>", [], null, callbackFn);