public static async Task StoreObjectAsync(string key, object value, LifetimeProfile profile) { if (CacheIsEnable) { await StoreObjectAsync(key, value, TimeSpan.FromMinutes((int)profile)); } }
public static void StoreObject(string key, object value, LifetimeProfile profile) { if (CacheIsEnable) { StoreObject(key, value, TimeSpan.FromMinutes((int)profile)); } }
public static ReturnType InvokeWithCache <ReturnType>(LifetimeProfile profile, string key, Func <ReturnType> action) { object obj = CacheManager.GetObject(typeof(ReturnType), key); if (obj == null) { obj = action.Invoke(); CacheManager.StoreObject(key, obj, TimeSpan.FromMinutes((int)profile)); } return((ReturnType)obj); }
public static async Task <ReturnType> InvokeWithCacheAsync <ReturnType>(LifetimeProfile profile, string key, Func <Task <ReturnType> > action) { object obj = await CacheManager.GetObjectAsync(typeof(ReturnType), key); if (obj == null) { obj = await action.Invoke(); if (obj != null) { CacheManager.StoreObjectAsync(key, obj, TimeSpan.FromMinutes((int)profile)); } } return((ReturnType)obj); }