Cache Management XML definition
The cache configuration is centered on a XML structure that defines the various caches. The following code segment is a sample XML –for cache configuration:
<?xml version="1.0" encoding="UTF-8"?> <AllCaches> <Cache Id="MY_CACHE_ID" Scope="application" Preload="Y"> <Handler>com.intellectdesign.myapp.MyCacheSourceHandler</Handler> <HandlerParams> <Param Name="MY_PARAM_1">Param 1 Value</Param> <Param Name="MY_PARAM_2">Param 2 Value</Param> </HandlerParams> </Cache> </AllCaches>
Let us look at each of the element of the Cache Management XML.
XML Element: AllCaches
This is the root element within the cache configuration XML. The attributes and child elements supported at the root element are:
Key | Relation Type | Multiplicity | Purpose |
---|---|---|---|
mode | Attribute | – | This is an optional attribute that is set at the root element to indicate whether the cache should make remote connections for invocation of its handler. Possible values are:
|
Cache | Child Element | 1..n | This is the child element under the root that indicates a cache definition. |
The following code segment is a sample –for the AllCaches element:
<?xml version="1.0" encoding="UTF-8"?> <AllCaches mode="local"> </AllCaches>
XML Element: Cache
This is the child element under the root that indicates a cache definition. One entry corresponds to a single cache definition. The attributes and child elements supported by the Cache element are:
Key | Relation Type | Multiplicity | Purpose |
---|---|---|---|
Id | Attribute | – | This is the unique ID for the cache within the Cache Management layer. All access to the cache from within the application is done using this ID. |
Scope | Attribute | – | This is a mandatory attribute that indicates the scope of the cache being defined. Possible values are:
|
Preload | Attribute | – | This is a Flag attribute at a cache level that indicates whether the cache should be loaded at startup of the Caching system. Possible values are:
|
ExpiryInterval | Attribute | – | This attribute indicates the time in milliseconds post which the cache is to be considered stale. If not provided or if the value is 0, the cache is considered to be in sync with its data for ever after initial load. |
Validating | Attribute | – | This is a flag attribute at a cache level that indicates whether the cache has to check for data staleness before returning the data. This provides a hook to the handler for reporting the staleness of the cache and based on the handler feedback returns the cache data or reloads the data into the cache. Possible values are:
|
Handler | Child Element | 1 | This is a child of the Cache element. This is the Java class that will provide the data for the cache. This is a mandatory configuration to be provided for a cache. |
HandlerParams | Child Element | 0..1 | This is a child of the Cache element. This is an optional element that can be used for passing any parameters to the handler for the handler's execution. The parameters are user-defined. The handler can validate the parameters provided at the time of XML parsing and initialization itself before the parameters are used. |
The following code segment is a sample entry –for the Cache element:
<?xml version="1.0" encoding="UTF-8"?> <AllCaches> <Cache Id="MY_CACHE_ID" Scope="application" Preload="Y" ExpiryInterval="10000" Validating="N"> </Cache> </AllCaches>
The options Preload, ExpiryInterval, and Validating are not applicable for caches defined with the scope as session. If provided, these are ignored.
XML Element: Handler
This is a child of the Cache element. This is the Java class that provides the data for the cache. This is a mandatory configuration to be provided for a cache. The class provided should be a sub-class of com.intellectdesign.canvas.cache.handler.CacheDataBuilder. This element does not support any attributes or child elements.
The following code segment is a sample entry –for the Handler element:
<?xml version="1.0" encoding="UTF-8"?> <AllCaches> <Cache Id="MY_CACHE_ID" Scope="application" Preload="Y" ExpiryInterval="10000" Validating="N"> <Handler>com.intellectdesign.myapp.MyCacheSourceHandler</Handler> </Cache> </AllCaches>
XML Element: HandlerParams
This is a child of the Cache element. This is an optional element that can be used for passing any parameters to the handler for the handler's execution. The parameters are user-defined. The handler can validate the parameters provided at the time of XML parsing and initialization itself before the parameters are used. The attributes and child elements supported by this element are:
Key | Relation Type | Multiplicity | Purpose |
---|---|---|---|
Param | Child Element | 1..n | This is a child of the HandlerParam element. If the HandlerParam is provided, then one or more parameters have to be defined. This has a Name attribute for defining the parameter name and the element value is the parameter value. |
Name | Attribute | – | This is the attribute associated with the Param element for defining the name of the parameter. If there are duplicates, then the value that will be used is indeterminate. |
The following code segment is a sample entry –for the HandlerParams element:
<?xml version="1.0" encoding="UTF-8"?> <AllCaches> <Cache Id="MY_CACHE_ID" Scope="application" Preload="Y" ExpiryInterval="10000" Validating="N"> <Handler>com.intellectdesign.myapp.MyCacheSourceHandler</Handler> <HandlerParams> <Param Name="MY_PARAM_1">Param 1 Value</Param> <Param Name="MY_PARAM_2">Param 2 Value</Param> </HandlerParams> </Cache> </AllCaches>