namespace IStation.Service
{
///
/// 缓存辅助类
///
public class AnalysisPumpCacheHelper
{
private const string _contentKey = "AnalysisPumpDictKey";
// 查询缓存键
private static string GetCacheKey()
{
return CacheKeyHelper.GetCacheKey(_contentKey);
}
///
/// 设置缓存
///
public static void Set(Dictionary> list, int minutes = 30, int randomSeconds = 0)
{
var cacheKey = GetCacheKey();
MemoryCacheHelper.Set(cacheKey, list, minutes * 60 + randomSeconds);
}
///
/// 查询缓存
///
public static Dictionary> Get()
{
var cacheKey = GetCacheKey();
return MemoryCacheHelper.Get>>(cacheKey);
}
///
/// 查询设置缓存
///
public static Dictionary> GetSet(Func>> func, int minutes = 30, int randomSeconds = 0)
{
var cacheKey = GetCacheKey();
return MemoryCacheHelper.GetSet(cacheKey, func, minutes * 60 + randomSeconds);
}
///
/// 移除缓存
///
public static void Remove()
{
var cacheKey = GetCacheKey();
MemoryCacheHelper.Remove(cacheKey);
}
///
/// 发布
///
public static void Publish(string Key)
{
var cacheKey = GetCacheKey();
MemoryCacheWipeRelationHelper.Set(Key, cacheKey);
}
///
/// 触发
///
public static void Trigger()
{
var cacheKey = GetCacheKey();
MemoryCacheWipeRelationHelper.Trigger(cacheKey);
}
}
}