Пример #1
0
        internal static T GetItemFromCache <T>(string key)
            where T : class
        {
            T t;

            try
            {
                t = (T)HttpRuntime.get_Cache().Get(key);
                if (t != null)
                {
                    t = MlcSlcCache.DeepClone <T>(t);
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                Logger.ErrorFormat(LogMessages.SqlDacs.Caching.ExtractingItemError, exception, new object[] { key });
                t = default(T);
            }
            return(t);
        }
Пример #2
0
 internal static void InsertItemInCache <T>(string key, T item, AggregateCacheDependency dependency, TimeSpan slidingExpiration, CacheItemPriority priority)
 {
     try
     {
         T t = item;
         if (item != null)
         {
             t = MlcSlcCache.DeepClone <T>(item);
         }
         if (!EqualityComparer <T> .Default.Equals(t, default(T)))
         {
             HttpRuntime.get_Cache().Insert(key, t, dependency, Cache.NoAbsoluteExpiration, slidingExpiration, priority, null);
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         Logger.ErrorFormat(LogMessages.SqlDacs.Caching.InsertItemError, exception, new object[] { key });
         throw;
     }
 }