zoukankan      html  css  js  c++  java
  • .Net缓存

    近期研究了一下.Net的缓存,据说可以提高系统的性能。

    .Net缓存分为两种HttpRuntime.Cache和HttpContext.Current.Cache

    不过从网上查找资料,说两种缓存其实是一样的,只是后者对前者进行了封装,在使用的时候推荐HttpRuntime.Cache的方式。

     1 //SetCache
     2 
     3 Cache objCache = HttpRuntime.Cache;
     4 objCache.Insert(CacheKey, objObject, dep, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(2));
     5 
     6 //GetCache
     7 
     8 System.Web.Caching.Cache objCache = HttpRuntime.Cache;
     9 return objCache[CacheKey];
    10 
    11 //RemoveCache
    12 
    13 System.Web.Caching.Cache objCache = HttpRuntime.Cache;
    14 if (objCache != null)
    15 {
    16 if (objCache.Get(CacheKey) != null)
    17 {
    18 objCache.Remove(CacheKey);
    19 }
    20 }
  • 相关阅读:
    SQLAlchemy Table(表)类方式
    MySQL简单入门
    第四次作业
    第三次随笔
    第二次随笔
    第一次随笔
    第四次随笔
    第三次作业
    第二次随笔
    第一次随笔
  • 原文地址:https://www.cnblogs.com/kevin-h-wang/p/3497685.html
Copyright © 2011-2022 走看看