skip to main content
Corticon Server: Data Integration Guide : Advanced EDC Topics : Using caches in EDC for entities and queries : 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. 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.

Testing caching on a Studio Ruletest to Run in Studio

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 in the Studio's space. To enable caching on the Ruletest, choose the Ruletest menu command Testsheet > EDC Database Access > Enable Cache, as shown:
When you run the Ruetest in Studio, you can observe its performance against your Input. There are no local files that are user modifiable.

Executing a Studio Ruletest against a deployed Decision Service

You can run your Ruletests against the Decision Service deployed on Corticon Server where you can tune the cache configuration of each Decision Service instance. The optimal way to manage a cache-enabled Decision Service is as follows:
1. In Studio, package the Decision Service and its Datasource Configuration file in a location that is accessible from the Web Console user's machine. When you deploy a Decision Service to a Server together with its Datasource Configuration file, all the Vocabulary and Rulesheet cache choices that you specified are packaged in the Decision Service.
2. In a web browser, connect to the Web Console that manages the server where you will deploy the Decision Service–perhaps a production-quality machine reserved for testing.
3. In the Web Console, add a Decision Service. Locate the EDS file, and then on the Database tab, locate the Datasource Configuration file.
4. Choose the EDC database settings that were on the Ruletest, as shown:
5. Click Save and Deploy.
Note: Once deployed, you can run Ruletests in Studio by changing the Test Subject to Run against Server, and then choosing your deployed Decision Service. However, the EDC Database Access settings on the Ruletest are ignored. Instead, use the corresponding options on the deployed Decision Service through the Web Console.
If you want to tune the cache configuration, see Modifying a cache configuration .
Note: Using Scripts - An alternate approach to enabling cache on a server is by using scripts, either testServerAxis or testServer. The command 103's ninth parameter is Database Access Cache (true or false) where true enables caching. The disadvantages of this technique is that the Decision Service is seen in the Web Console as unmanaged so it cannot be edited there. For more information, see the topic Using Server API to compile and deploy Decision Services .
Important: Turning caching on or off - If you want to enable or disable caching on a deployed Decision Service, the mechanisms of caching require that you undeploy and delete the Decision Service, and then add and deploy the Decision Service again with the cache enablement setting you want.

Cache files and configuration on Corticon Server

On Corticon Servers:
*Each Decision Service maintains 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.
*Each Decision Service records its 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.

Properties in a cache configuration

The first run of the Decision Service on a Corticon Server creates its cache configuration file. The default properties and values for the deployed Decision Service ehcache_Cargo_v0.16.eds are in its configuration file ehcache_Cargo_v0.16.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<diskStore path="[CORTICON_WORK_DIR]\Server\etc\Cargo_v0.16.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 TTL 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.

Modifying a cache configuration

If you want to modify any of the cache configuration properties for a Decision Service deployed on Corticon Server, you need to follow these steps for each Decision Service instance, as illustrated for ehcache_Cargo_v0.16.xml:
1. Run the deployed Decision service with its cache enabled to create its default configuration file in etc.
2. Edit the file to specify your preferred property values and then save it.
3. Add the folder and the explicit filename, in this case etc\ehcache_Cargo_v0.16.xml, to the server classpath.
4. Edit the Decision Service's deployed Datasource Configuration file to add the location of the configuration file relative to the classpath as a property, as illustrated:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<decisionService>
<datasources>
<edc useForQueryService="false" description="" name="EDC">
<connection-url>jdbc:progress:sqlserver://localhost:1433;
databaseName=PatientRecords</connection-url>
<database-driver>com.corticon.database.id.MsSql2014</database-driver>
<password>062046016058035029061039110</password>
<username>061046</username>
<properties>
<property name="net.sf.ehcache.configurationResourceName"
value="..\..\..\..\..\etc\ehcache_Cargo_v0.16.xml"/>
</properties>

</edc>
</datasources>
</decisionService>
where value is the appropriate relative location.
5. Restart the Server to apply the changes.
Note: For more information about the settings and behaviors of Corticon's advanced EDC caching, see the Ehcache 2.4.3 documentation.