You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
704 B
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Caching;
namespace BP.Difference
{
public static class CacheHelper
{
private static MemoryCache mc = MemoryCache.Default;
public static bool Contains(string key)
{
return mc.Contains(key);
}
public static T Get<T>(string key)
{
return (T)mc.Get(key);
}
public static void Add<T>(string key, T v)
{
CacheItemPolicy p = new CacheItemPolicy();
mc.Add(key, (object)v, p);
}
public static void Remove(string key)
{
mc.Remove(key);
}
}
}