Cache 操作类

public class CacheManage
    {
        public static Object GetCache(string cacheKey)
        {
            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return HttpRuntime.Cache[cacheKey];
            }
            return null;
        }

        public static void Insert(string cacheKey, Object obj)
        {
            HttpRuntime.Cache.Insert(cacheKey, obj, null, DateTime.Now.AddMinutes(60), System.Web.Caching.Cache.NoSlidingExpiration);
        }
        public static void Insert(string cacheKey, Object obj, int minutes)
        {
            HttpRuntime.Cache.Insert(cacheKey, obj, null, DateTime.Now.AddMinutes(minutes), System.Web.Caching.Cache.NoSlidingExpiration);
        }
        public static void Insert(string cacheKey, Object obj, double Seconds)
        {
            HttpRuntime.Cache.Insert(cacheKey, obj, null, DateTime.Now.AddSeconds(Seconds), System.Web.Caching.Cache.NoSlidingExpiration);
        }
        public static void Remove(string cacheKey)
        {
            HttpRuntime.Cache.Remove(cacheKey);
        }
    }

posted on 2014-07-25 12:05  忙碌ing  阅读(174)  评论(0)    收藏  举报

导航