using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.BLL { /// /// PumpCurve缓存辅助类 /// internal class PumpCurveCacheHelper { private const string _contentKey = "PumpCurveListKey"; private static string GetCacheKey(long CorpID) { var contentKey = string.Format("{0}-{1}", _contentKey, CorpID); return CacheHelper.GetCacheKey(contentKey); } /// /// 设置缓存 /// public static void Set(long CorpID, List list, int Minites = 30, int RandomSeconds = 0) { var cacheKey = GetCacheKey(CorpID); MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds); } /// /// 获取缓存 /// public static List Get(long CorpID) { var cacheKey = GetCacheKey(CorpID); return MemoryCacheHelper.Get>(cacheKey); } /// /// 获取设置缓存 /// public static List GetSet(long CorpID, Func> func, int Minites = 30, int RandomSeconds = 0) { var cacheKey = GetCacheKey(CorpID); return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds); } /// /// 移除缓存 /// public static void Remove(long CorpID) { var cacheKey = GetCacheKey(CorpID); MemoryCacheHelper.Remove(cacheKey); } /// /// 全部移除 /// public static void RemoveAll() { MemoryCacheHelper.Remove((key) => { return key.Contains(CacheHelper.GetCacheKey(_contentKey)); }); } } }