Iterating Items in the Cache

  • Updated

Namespaces: InRule.Runtime
Classes:   RuleApplicationReference
See Also: Creating a RuleSession with Cache Retention, Controlling Compilation and Cache Retention, Adding Items into the Cache, Working with the Rule Application Cache
References: InRule.Runtime.dll, InRule.Common.dll

You can iterate through all the cache entries to get information:

public string GetCacheEntriesInfo()
    var sb = new StringBuilder();
    // Get the existing cache entries from the RuleSession - this returns
    // a set of RuleApplicationReferences
    IEnumerable<RuleApplicationReference> cacheEntries;
    cacheEntries = RuleSession.RuleApplicationCache.Items;
    foreach (RuleApplicationReference cacheEntry in cacheEntries)
        // Extract information from the rule application
        sb.AppendLine("Rule App Name:" + cacheEntry.GetRuleApplicationDef().Name);
        sb.AppendLine("Unique Name:" + cacheEntry.Name);

        // if it has been compiled, you can get properties such as time
        if (cacheEntry.LastMetadataCompile != null)
            DateTime lastMetaCompileTime = cacheEntry.LastMetadataCompile.Value.UtcDateTime;
            sb.AppendLine("Last metadata compile:" + lastMetaCompileTime.ToString());
        // get information about its rank in the cache
        sb.AppendLine("Cache retention rank:" + cacheEntry.CacheRetention.Weight.ToString());
    return sb.ToString();

Was this article helpful?

0 out of 0 found this helpful



Please sign in to leave a comment.