public GetConfig ( |
||
implementation | ||
return |
/// <summary> /// Returns from the cache provider the value saved with the key generated /// using the specified <code>IMethodInvocation</code>. If the object is not /// found in the cache, the intercepted method is executed and its returned /// value is saved in the cached and returned by this method. /// </summary> /// <param name="invocation">the description of the intercepted method.</param> /// <param name="args">the arguments of the intercepted method.</param> /// <returns>the object stored in the cache.</returns> public object Intercept(IMethodInvocation invocation, params object[] args) { CacheConfig config = _cacheConfigHolder.GetConfig(invocation.Method.DeclaringType); if (config != null && config.IsMethodCache(invocation.Method)) { ICacheManager cacheManager = config.GetCacheManager(invocation.Method); String cacheKey = cacheManager.CacheKeyGenerator.GenerateKey(invocation, args); object result = cacheManager[cacheKey]; if (result == null) { //call target/sub-interceptor result = invocation.Proceed(args); //cache method result if (result == null) { cacheManager[cacheKey] = NULL_OBJECT; } else { cacheManager[cacheKey] = result; } } else if (result == NULL_OBJECT) { // convert the marker object back into a null value result = null; } return(result); } else { return(invocation.Proceed(args)); } }