using Yw;
|
|
namespace IStation.Service
|
{
|
/// <summary>
|
/// PumpCurve缓存辅助类
|
/// </summary>
|
internal class PumpCurveCacheHelper
|
{
|
private const string _contentKey = "PumpCurveListKey";
|
|
private static string GetCacheKey()
|
{
|
var contentKey = string.Format("{0}", _contentKey);
|
return CacheHelper.GetCacheKey(contentKey);
|
}
|
|
/// <summary>
|
/// 设置缓存
|
/// </summary>
|
public static void Set(List<Model.PumpCurve> list, int Minites = 30, int RandomSeconds = 0)
|
{
|
var cacheKey = GetCacheKey();
|
MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds);
|
}
|
|
/// <summary>
|
/// 查询缓存
|
/// </summary>
|
public static List<Model.PumpCurve> Get()
|
{
|
var cacheKey = GetCacheKey();
|
return MemoryCacheHelper.Get<List<Model.PumpCurve>>(cacheKey);
|
}
|
|
/// <summary>
|
/// 查询设置缓存
|
/// </summary>
|
public static List<Model.PumpCurve> GetSet(Func<List<Model.PumpCurve>> 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);
|
}
|
|
/// <summary>
|
/// 全部移除
|
/// </summary>
|
public static void RemoveAll()
|
{
|
MemoryCacheHelper.Remove((key) =>
|
{
|
return key.Contains(CacheHelper.GetCacheKey(_contentKey));
|
});
|
}
|
|
|
}
|
}
|