using System;
using System.Runtime.Caching;
/// <summary>
/// .net本地缓存
/// </summary>
public class LocalCache
{
private static volatile MemoryCache _cache;
static LocalCache()
{
_cache = MemoryCache.Default;
}
public void Set(string key, string content, DateTime expiretime)
{
_cache.Set(key, content, DateTime.SpecifyKind(expiretime, DateTimeKind.Local));
}
public string Get(string key)
{
object obj = _cache.Get(key);
if (obj == null)
{
return string.Empty;
}
return obj.ToString();
}
}