static void Main(string[] args)
{
Console.WriteLine("*************************************************************");
for (int i = 0; i < 5; i++)
{
MemoryCacheUtil.AddCacheItem<string>(i.ToString(), () => i + "-000-" + i, null, DateTime.Now.AddMinutes(30));
}
for (int i = 0; i < 5; i++)
{
var cache = MemoryCacheUtil.GetCacheItem<string>(i.ToString());
Console.WriteLine(cache);
}
MemoryCacheUtil.ClearCache();
for (int i = 0; i < 5; i++)
{
var cache = MemoryCacheUtil.GetCacheItem<string>(i.ToString());
Console.WriteLine(cache);
}
}
public static class MemoryCacheUtil
{
public static bool Contains(string key)
{
return MemoryCache.Default.C