Cache Plus Memory — For Constants and Less Changeable Objects

With the cache plus memory setting, the entity objects are serialized and are always available in cache.

There is one object in the cache (in a logical sense), and any number of references (handles) to that object in each JVM. References to the entities are tracked in the working memory so they can be deserialized and retrieved from the cache when needed by the engine.

The agent’s working memory is used to store the Rete network for the loaded rules. The inference agent does not store the actual object. It relies on the object management layer to load the objects on demand from the backing store. For example, consider a rule of this form:

Declaration (Scope): Customer
Condition: Customer.age < 20

If the cache mode is cache plus memory, then working memory stores handles to all customers, including those whose age is greater than 20. The customer objects for customers whose age is less than 20 are deserialized and retrieved from cache when the rule condition is evaluated, in order to process the rule.

Because a Rete network is so large, the references themselves can consume large amounts of memory. To reduce the memory footprint, it is recommended that you use the Cache Only mode for most entity types.

In addition, the Cache Only mode is more straightforward to use as there is less to synchronize in a multi-agent environment when the Rete network is flushed after each RTC.

Appropriate locking in complex projects that use concurrency features can be difficult with cache plus memory.