Modifying the event cache duration

You can reduce the time that events stay in memory by setting the eventCacheDuration property in the solution_properties.xml file.

About this task

The eventCacheDuration specifies the maximum amount of time that Decision Server Insights keeps an event in memory after the event is processed.

The property is only applicable when database persistence is enabled. The backingMap for the Event Store is defined in the objectgrid.xml file of each runtime server. Events that are used after the event cache duration are fetched from the database and are restored in memory. Both the eventCacheDuration property and the timeToLive attribute contribute to reducing the number of events in memory.

The timeToLive attribute sets the time, in seconds, to keep events in the Event Store map after they are restored from the database. The default value is 1 year, as shown in the following example.

<backingMap name="EventStore.*"
            template="true" 
            lockStrategy="PESSIMISTIC" 
            copyMode="COPY_TO_BYTES"
            pluginCollectionRef="EventStorePlugins" 
            ttlEvictorType="LAST_UPDATE_TIME" 
            timeToLive="31536000"/>

You can also set the eventCacheDuration property by running the propertyManager set command.

Procedure

Open the solution_properties.xml file that is in the root folder of the solution project and add the eventCacheDuration property.
Note: To reduce the time that events are kept in memory, the eventCacheDuration value must be less than the maxHorizon value. To keep events resident in memory, set eventCacheDuration to be equal to maxHorizon.

If the eventCacheDuration is set to be shorter that the time horizons used by the solution, then events are removed from memory. If an event instance needs to be referenced again after it is removed from memory, it is reloaded from the backing database.

If the eventCacheDuration is set to be longer than the time horizons used by the solution, then events are kept in memory. Events remain available without having to be reloaded in case they are needed during the processing of a subsequent event.

Example

If you have customer entities, which receive multiple events for about an hour, but then become inactive for more than a week. You might want to keep any events needed for rules processing in memory for the hour. You can reduce memory requirements by specifying a lower eventCacheDuration for the remainder of the week:
<property name="eventCacheDuration">PT1H</property>
The value is set to 1 hour. For more information, see Server administration properties.

When events are required later, they are reloaded from the backing database. To keep the reloaded events in memory for an hour, set the timeToLive attribute to 3600.