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