Esempio n. 1
0
 public static async Task StoreObjectAsync(string key, object value, LifetimeProfile profile)
 {
     if (CacheIsEnable)
     {
         await StoreObjectAsync(key, value, TimeSpan.FromMinutes((int)profile));
     }
 }
Esempio n. 2
0
 public static void StoreObject(string key, object value, LifetimeProfile profile)
 {
     if (CacheIsEnable)
     {
         StoreObject(key, value, TimeSpan.FromMinutes((int)profile));
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }