private T GetData <E, M, T>(string cacheKey, Func <Func <E, M>, T> getData, Func <E, M> transformData) where T : class { T data = IsCacheEnabled ? InnerCache.Get <T>(cacheKey) : null; if (data == null) { data = getData(transformData); } return(data); }
private T GetData <T>(string cacheKey, Func <T> getData) where T : class { T data = IsCacheEnabled ? InnerCache.Get <T>(cacheKey) : null; if (data == null) { data = getData(); } return(data); }
protected override bool TryGetInner <TValue>(string key, out TValue value) { object val = InnerCache.Get(key, null); if (val != null) { value = Newtonsoft.Json.JsonConvert.DeserializeObject <TValue>(val.ToString()); return(true); } value = default(TValue); return(false); }
protected override bool TryGetInner <TValue>(string key, out TValue value) { var item = InnerCache.Get(key, null) as CacheItem; if (item != null) { hits++; // ReSharper disable once CanBeReplacedWithTryCastAndCheckForNull value = item.Value is TValue ? (TValue)item.Value : default(TValue); return(true); } misses++; value = default(TValue); return(false); }
protected virtual CacheMethodTaken TryGetScopedInner <TValue>(String key, out ScopedValue <TValue> value) { var directives = CacheDirectives.CurrentScope; if (!directives.Method.HasFlag(CacheMethod.Get)) { value = default; return(CacheMethodTaken.None); } if (InnerCache.Get(key, regionName: null) is ScopedValue <TValue> scopedValue && directives.IsInScope(scopedValue)) { value = scopedValue; return(CacheMethodTaken.Get); } value = default; return(CacheMethodTaken.GetMiss); }
public TValue Get(TKey key, Func <TKey, TValue> factory) { return(InnerCache.Get(key, factory)); }