skip to main content
Corticon Server: Integration & Deployment Guide : Implementing EDC : Working with EDC in Corticon Server : Working with database caches
 

Try Corticon Now
Working with database caches
Corticon's EDC provides functionality for enhanced database caching at runtime. Its cache is temporary data that duplicates data located in a database so that it can be repeatedly accessed with minimal costs in terms of time and resources. If an application must be certain not to get stale data, then it should not use caching. Caching is best used for reference data such as tax or actuarial tables.
What gets cached is based on settings in a project's Vocabulary and Rulesheets (see the topic Defining database caching in Studio ). Ruletests and deployed Decision Services let you choose to enable the requested caching. The first cache usage takes some overhead to establish the cache so that subsequent test runs get the benefit of very fast performance. When Studio or Server restarts, its in-memory cache(s) and on-disk cache files are cleared.

Enabling caching on a Studio Ruletest

Once you have Rulesheets and a Vocabulary that are prepared for database caching, choosing to enable cache on the Studio will perform the caching functions. To enable caching on the Ruletest, choose the Ruletest menu command Testsheet > Database Access > Enable Cache, as shown:
When the Ruletest runs, it records its default configuration in the Studio's one DB Cache properties file, [CORTICON_WORK_DIR]\etc\ehcache.xml, which it creates during the first run. If the memory cache overflows, the cache files are created on the Studio machine. While the default settings should provide good performance, you can adjust the cache configuration as discussed later in this topic.
Enabling caching on deployed Decision Services
On Corticon Servers, no Decision Services are enabled for database caching by default. You set the preference to enable caching on each Decision Service during its deployment process, as available in these various deployment techniques:
*Using Corticon Web Console - Adding or editing a Decision Service in an application, as described in the topic Add or Edit a Decision Service
*Using scripts testServerAxis and testServer - Command 103 includes a parameter for enabling caching. Those commands use the underlying Using the Corticon Server APIs. For more information, see the topic Using Server API to compile and deploy Decision Services.
On Corticon Servers, each Decision Service records its respective default configuration in its properties file, [CORTICON_WORK_DIR]/etc/ehcache_<DSName>_v<M.m>.xml where <DSName>_v<M.m> is the named and versioned Decision Service. For example, [CORTICON_WORK_DIR]\etc\ehcache_Cargo_v0.16.xml. Each Decision Service will also maintain its own cache, and cached data is never shared between Decision Services. Undeploying a Decision Service immediately clears its cache in memory and on disk.
Setting properties in a cache configuration
Once the cache configuration file has been created for Studio or for a deployed Decision Service, you can adjust its properties such as controlling the refresh intervals. The default properties and values are:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<diskStore path="[CORTICON_WORK_DIR]\Server\etc\ehcache.xml" />
<defaultCache
overflowToDisk="true"
timeToLiveSeconds="120"
timeToIdleSeconds="120"
eternal="false"
maxElementsInMemory="1000" />
</ehcache>
where:
*diskStore path is the location where overflows to disk are written.
*overflowToDisk sets whether elements can overflow to disk when the in-memory cache has reached the maxElementsInMemory limit.
*timeToLiveSeconds is the maximum number of seconds an element can exist in the cache regardless of use. The element expires at this limit and will no longer be returned from the cache. If the value is 0, no TTL eviction takes place (infinite lifetime).
*timeToIdleSeconds is the maximum number of seconds an element can exist in the cache without being accessed. The element expires at this limit and will no longer be returned from the cache. If the value is 0, no TTI eviction takes place (infinite lifetime).
*eternal sets whether elements are eternal. When eternal is true, timeouts are ignored and elements are never expired.
*maxElementsInMemory is the maximum number of objects that will be created in memory. When set to 0, there is no limit.
Note: For more information about the settings and behaviors of Corticon's advanced EDC caching, see the EHCACHE documentation.