Creating a RuleSession with Cache Retention

  • Updated

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

The rule session object object that manages all of the rules engine request directives and execution results.  The rule session is used to load state, execute rules, and retrieve notifications, validations, and the execution log.

Cache retention controls how a session is stored in the cache

// Create a rule session with a rule application reference and

// specifying the cache retention
RuleSession ruleSession = new RuleSession(ruleAppRef, CacheRetention.AlwaysRetain);

// Create a rule session with a rule application definition reference and

// specifying the cache retention
RuleSession ruleSession = new RuleSession(ruleAppDef, CacheRetention.AlwaysRetain);

// Using Rule Application Definition that has been saved to file to create

// a rule session and specifying the cache retention
RuleSession ruleSession = new RuleSession(@"C:\temp\ruleAppDef", CacheRetention.AlwaysRetain);

// Using the cache retention weight to control how an rule application will be kept in the cache

// Higher values are more likely to be retained; Lower valies are less likely to be retained

// and therefore expired from the cache. 1000 is the default weight.
RuleSession ruleSession = new RuleSession(ruleAppRef, CacheRetention.FromWeight(5000));

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.