| | |
| | | namespace HStation.Service |
| | | { |
| | | /// <summary> |
| | | /// PumpGroup |
| | | /// AssetsPumpGroup |
| | | /// 缓存辅助类 |
| | | /// </summary> |
| | | internal class PumpGroupCacheHelper |
| | | internal class AssetsPumpGroupCacheHelper |
| | | { |
| | | private const string _contentKey = "PumpGroupList"; |
| | | private const string _contentKey = "AssetsPumpGroupList"; |
| | | |
| | | internal static string GetCacheKey() |
| | | { |
| | |
| | | /// <summary> |
| | | /// 设置缓存 |
| | | /// </summary> |
| | | public static void Set(List<Model.PumpGroup> list, int Minites = 30, int RandomSeconds = 0) |
| | | public static void Set(List<Model.AssetsPumpGroup> list, int Minites = 30, int RandomSeconds = 0) |
| | | { |
| | | var cacheKey = GetCacheKey(); |
| | | MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds); |
| | |
| | | /// 获取缓存 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<Model.PumpGroup> Get() |
| | | public static List<Model.AssetsPumpGroup> Get() |
| | | { |
| | | var cacheKey = GetCacheKey(); |
| | | return MemoryCacheHelper.Get<List<Model.PumpGroup>>(cacheKey); |
| | | return MemoryCacheHelper.Get<List<Model.AssetsPumpGroup>>(cacheKey); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取设置缓存 |
| | | /// </summary> |
| | | public static List<Model.PumpGroup> GetSet(Func<List<Model.PumpGroup>> func, int Minites = 30, int RandomSeconds = 0) |
| | | public static List<Model.AssetsPumpGroup> GetSet(Func<List<Model.AssetsPumpGroup>> func, int Minites = 30, int RandomSeconds = 0) |
| | | { |
| | | var cacheKey = GetCacheKey(); |
| | | return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds); |