public CacheResultInfo(CacheResultAttribute resultInfo, CacheResultItemsAttribute[] itemInfoArray) { ResultInfo = resultInfo; ItemInfoArray = itemInfoArray; }
/// <summary> /// Caches each item from the collection returned by target method. /// </summary> /// <param name="items"> /// A collection of items to cache. /// </param> /// <param name="itemInfoArray"> /// Attributes specifying where and how to cache each item from the collection. /// </param> /// <param name="vars"> /// Variables for expression evaluation. /// </param> private void CacheResultItems(IEnumerable items, CacheResultItemsAttribute[] itemInfoArray, IDictionary vars) { foreach (CacheResultItemsAttribute itemInfo in itemInfoArray) { AssertUtils.ArgumentNotNull(itemInfo.KeyExpression, "Key", "The cache attribute is missing the key definition."); ICache cache = GetCache(itemInfo.CacheName); #region Instrumentation bool isDebugEnabled = logger.IsDebugEnabled; #endregion foreach (object item in items) { if (EvalCondition(itemInfo.Condition, itemInfo.ConditionExpression, item, vars)) { object itemKey = itemInfo.KeyExpression.GetValue(item, vars); #region Instrumentation if (isDebugEnabled) { logger.Debug("Caching collection item for key [" + itemKey + "]."); } #endregion cache.Insert(itemKey, (item == null ? NullValue : item), itemInfo.TimeToLiveTimeSpan); } } } }