using Microsoft.Extensions.Caching.Memory;
using System;
using System.Web;
///
/// 数据缓存操作类 author by zhaorui 2021-3-6
///
namespace ZR.Common
{
public class CacheHelper
{
public static MemoryCache Cache { get; set; }
static CacheHelper()
{
Cache = new MemoryCache(new MemoryCacheOptions
{
//SizeLimit = 1024
});
}
///
/// 全局缓存时间
///
public static int CacheTime = 5; //ConfigHelper.GetConfigInt("CacheTime");
///
/// 获取缓存
///
///
///
///
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