MemoryCache的使用
using System.Runtime.Caching;
MemoryCache mc = MemoryCache.Default; string cacheKey = "mykey"; var value = ""; if (mc.Contains(cacheKey)) { var cacheItem = mc.Get(cacheKey); value = cacheItem as string; } else { value = "5555"; CacheItemPolicy policy = new CacheItemPolicy(); policy.AbsoluteExpiration = DateTime.Now.AddMinutes(100); mc.Add(cacheKey, value , policy); }