.Net 使用 MemoryCache

   Develop  .Net    Develop  .Net

程序集

System.Runtime.Caching.MemoryCache

代码参见

1
2
3
4
5
6
7
8
9
10
ObjectCache cache = MemoryCache.Default;
string key = "_key";
System.Data.DataSet ds = cache[key] as System.Data.DataSet;
if(ds == null){
CacheItemPolicy policy = new CacheItemPolicy();
policy.AbsoluteExpiration =
DateTimeOffset.Now.AddMinutes(10);
cache.Set(key, ds, policy);
}
return ds
  1. 程序集
  2. 代码参见
VisualSVN 破解
.Net Core 使用 EF-Core