using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using IStation.Untity;
|
|
namespace IStation.Service
|
{
|
/// <summary>
|
/// SysDictData
|
/// 缓存辅助类
|
/// </summary>
|
internal class SysDictDataCacheHelper
|
{
|
private const string _contentKey = "SysDictDataListKey";
|
|
private static string GetCacheKey()
|
{
|
var contentKey = string.Format("{0}", _contentKey);
|
return CacheHelper.GetCacheKey(contentKey);
|
}
|
|
/// <summary>
|
/// 设置缓存
|
/// </summary>
|
public static void Set(List<Model.SysDictData> list, int Minites = 30, int RandomSeconds = 0)
|
{
|
var cacheKey = GetCacheKey();
|
MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds);
|
}
|
|
/// <summary>
|
/// 获取缓存
|
/// </summary>
|
/// <returns></returns>
|
public static List<Model.SysDictData> Get()
|
{
|
var cacheKey = GetCacheKey();
|
return MemoryCacheHelper.Get<List<Model.SysDictData>>(cacheKey);
|
}
|
|
/// <summary>
|
/// 获取设置缓存
|
/// </summary>
|
public static List<Model.SysDictData> GetSet(Func<List<Model.SysDictData>> func, int Minites = 30, int RandomSeconds = 0)
|
{
|
var cacheKey = GetCacheKey();
|
return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds);
|
}
|
|
/// <summary>
|
/// 移除缓存
|
/// </summary>
|
public static void Remove()
|
{
|
var cacheKey = GetCacheKey();
|
MemoryCacheHelper.Remove(cacheKey);
|
}
|
|
|
}
|
}
|