Managing the Cache

  • Updated

Prerequisites:  A valid RuleApplicationReference
Namespaces: InRule.Runtime
Classes:   RuleSession, RuleApplicationReference, FileSystemRuleApplicationReference,
InMemoryRuleApplicationReference, CatalogRuleApplicationReference
See Also: Retrieving a Rule Application, Creating a RuleSession, Creating a RuleSession with Cache
, Adding items into the Cache, Iterating items in the cache , Controlling Compilation and Cache

Compiling a rule application with delegates

When you compile your rule application, you can specify if executable code (delegates) will be compiled at the same time or only when needed. If you select the former, there will be a slower compile time, but the execution time will be faster.

// Compile the RuleApplicationReference, including the executable code (delegates)

Setting the degree of parallelism for compilation

You can direct InRule regarding how many threads or cores to use for parallel work when compiling a rule application. This value is a non-negative integer, which you set as follows:




on; InRule will decide based on the number of cores available


off; one thread will be used for all work (default)


the number of threads to use

// Compile the RuleApplicationReference, specifying at most two threads or cores
ruleAppRef.Compile(CompileSettings.Create(EngineLogOptions.None, 2));

Note: InRule recommends the default setting (0).

Adding a rule application to the cache

After compiling your rule application, you can speed up future executions by adding it to the rule session cache.

// Add the rule application to the rule application cache

Removing a rule application from the cache

Of course, you may also remove a rule application from the cache.

// Remove a rule application from the rule application cache

Clearing the rule application caches

From time to time, you may want to clear the caches completely. You may do this for the internal cache of a rule application, or for the entire rule session cache.

// Clear internal caches in a rule application reference

// Clear the entire rule application cache

Was this article helpful?

0 out of 0 found this helpful



Please sign in to leave a comment.