2021-03-21 15:51:49 +08:00
|
|
|
|
using Autofac;
|
2021-03-25 20:44:12 +08:00
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2021-03-21 15:51:49 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CC.Yi.Common.Cache
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CacheHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
public static ICacheWriter CacheWriter { get; set; }
|
|
|
|
|
|
static CacheHelper()
|
|
|
|
|
|
{
|
2021-04-15 16:49:35 +08:00
|
|
|
|
CacheHelper.CacheWriter = new RedisCache();
|
2021-03-21 15:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 16:49:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool AddCache<T>(string key, T value, DateTime expDate)
|
2021-03-21 15:51:49 +08:00
|
|
|
|
{
|
2021-04-15 16:49:35 +08:00
|
|
|
|
return CacheWriter.AddCache<T>(key,value,expDate);
|
2021-03-21 15:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 16:49:35 +08:00
|
|
|
|
public bool AddCache<T>(string key, T value)
|
2021-03-21 15:51:49 +08:00
|
|
|
|
{
|
2021-04-15 16:49:35 +08:00
|
|
|
|
return CacheWriter.AddCache<T>(key, value);
|
2021-03-21 15:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 16:49:35 +08:00
|
|
|
|
public bool RemoveCache(string key)
|
2021-03-21 15:51:49 +08:00
|
|
|
|
{
|
2021-04-15 16:49:35 +08:00
|
|
|
|
return CacheWriter.RemoveCache(key);
|
2021-03-21 15:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 16:49:35 +08:00
|
|
|
|
public T GetCache<T>(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CacheWriter.GetCache<T>(key);
|
2021-03-21 15:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 16:49:35 +08:00
|
|
|
|
public bool SetCache<T>(string key, T value, DateTime expDate)
|
2021-03-21 15:51:49 +08:00
|
|
|
|
{
|
2021-04-15 16:49:35 +08:00
|
|
|
|
return CacheWriter.SetCache<T>(key,value,expDate);
|
2021-03-21 15:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 16:49:35 +08:00
|
|
|
|
public bool SetCache<T>(string key, T value)
|
2021-03-21 15:51:49 +08:00
|
|
|
|
{
|
2021-04-15 16:49:35 +08:00
|
|
|
|
return CacheWriter.SetCache<T>(key, value);
|
2021-03-21 15:51:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|