using Microsoft.Extensions.Caching.Memory;
using System;
namespace ZR.Common
{
public class CacheHelper
{
public static MemoryCache Cache { get; set; }
static CacheHelper()
{
Cache = new MemoryCache(new MemoryCacheOptions
{
//SizeLimit = 1024
});
}
///
/// 获取缓存
///
///
///
///
public static T GetCache(string key) where T : class
{
if (key == null)
throw new ArgumentNullException(nameof(key));
//return Cache.Get(key) as T; //或者
return Cache.Get(key);
}
///
/// 获取缓存
///
///
///
public static object GetCache(string CacheKey)
{
return Cache.Get