Page tree
Skip to end of metadata
Go to start of metadata

To improve the runtime performance of a SWAT Framework-based application, the repository cache has been implemented to store the computed definition for all screens.
Once activated, performance is increased as the backend doesn't need to recompute the screen definitions, which can be a complex process.

Activation

Despite the improved performance, repository caching is disabled, by default, as it can interfere with the development process.
As implied, once a screen definition has been cached, it won't take into account any additional changes done to the screen itself until the cached version is removed.
To activate it, one simply needs to add the caching service to the application's services XML file:

Sample

<ttServiceLoaderRow>
   <Order>10</Order>
   <ServiceTypeName>Akioma.Swat.Repository.Cache.IRepositoryCacheService</ServiceTypeName>
   <ServiceClassName>Akioma.Swat.Repository.Cache.DatabaseRepositoryCacheService</ServiceClassName>
</ttServiceLoaderRow>

Configuration

The database repository cache service supports the following PASOE config XML entries:

Property nameDetails
RepositoryCacheSkipList

A comma-separated list of screen name patterns, which is used to exclude them from the cache so they are recalculated each time they are requested by the user.
The list is matched using ABL's CAN-DO's function, which allows the '*' character for 0 or more characters and '!' for a negation, which would mark a screen for caching.
By default, the property is empty so the service caches all the screens.

Customization

As seen in the 'Activation' section, the repository cache functionality has been implemented through a SmartComponent Library service (Akioma.Swat.Repository.Cache.DatabaseRepositoryCacheService).
This means that the service implements an interface (Akioma.Swat.Repository.Cache.IRepositoryCacheService) and all interactions with the service are done through the interface.
The SWAT Framework support only one repository cache service, DatabaseRepositoryCacheService, which stores the definition in the database.
The repository service fully supports custom implementations of the IRepositoryCacheService interface.

Interaction with dynamic screens

The base builder class now has a new property: 'DynamicDefinition'.
By default, the property is false, in which case any screen containing the corresponding control is unaffected.
Whenever a screen contains a control which has the dynamic definition property set to true, it will be automatically excluded from the build.
This has been introduced for custom controls, where the definition changes during runtime.
As such, it is up to the developer of the custom control to decide whether it is dynamic at runtime or only at design-time.

Clearing the cache

When screen changes are made in an environment where caching is enabled and the screen has been cached, the changes won't be visible.
For this, the clear cache functionality is available to remove the specified screens from the cache so the changed definition can be reconstructed.

As of SWAT Release 19.11.0, the repository cache service itself provides a clear cache method to clear all the screens matching the specified MATCHES pattern.

Clearing the whole cache through the service

DEFINE VARIABLE oCacheService AS Akioma.Swat.Repository.Cache.IRepositoryCacheService NO-UNDO.
oCacheService = {Consultingwerk/get-service.i Akioma.Swat.Repository.Cache.IRepositoryCacheService}.
IF VALID-OBJECT(oCacheService) THEN
oCacheService:ClearCache("*").

Additionally, there also are 2 procedures available to allow clearing caches from external scripts: 

  • Akioma/Swat/Repository/Cache/clear-repository-cache-be.p, which calls the clear cache method on Akioma.Swat.Repository.Cache.RepositoryCacheEntity

    Calling the procedure

    RUN Akioma/Swat/Repository/Cache/clear-repository-cache-be.p ("*").

  • Akioma/Swat/Repository/Cache/clear-repository-cache-be-pct.p, which calls into Akioma/Swat/Repository/Cache/clear-repository-cache-be.p and is compatible with PCT

    Calling the PCT-compatible procedure from ANT

    <PCTRun baseDir="${baseDir}"
    procedure="Akioma/Swat/Repository/Cache/clear-repository-cache-be-pct.p"
    graphicalMode="false" cpinternal="UTF-8" cpstream="UTF-8" cpcase="basic"
    inputchars="32000" token="4000" stackSize="500" msgBufferSize="1024"
    dirSize="10000" quickRequest="true" ttBufferSize="10000" >
    	<propath refid="${propathId}"/>
    <DBConnectionSet refId="${dbSetId}"/>
    <Parameter name="ContainerPattern" value="*"/>
    </PCTRun>

DEPRECATED:

The clear cache functionality is available by calling the business entity method 'ClearCache' of 'Akioma.Swat.Repository.Cache.RepositoryCacheEntity'.
The method accepts a Consultingwerk.CharacterHolder parameter, which is used as a 'MATCHES' pattern to identify all the cached definitions that need to be removed.
Below is a sample on how to clear the whole cache by calling the method with the '*' pattern:

DEFINE VARIABLE hDataset AS HANDLE NO-UNDO.
Consultingwerk.OERA.ServiceInterface:FetchDataset(Akioma.Swat.Repository.Cache.DatabaseRepositoryCacheService:CacheBusinessEntity, DATASET-HANDLE hDataset).
Consultingwerk.OERA.ServiceInterface:InvokeMethod(Akioma.Swat.Repository.Cache.DatabaseRepositoryCacheService:CacheBusinessEntity, "ClearCache", DATASET-HANDLE hDataset, NEW Consultingwerk.CharacterHolder("*")).
  • No labels