using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using IStation.Untity; namespace IStation.Service { /// /// CustomCronJob /// 缓存辅助类 /// internal class CustomCronJobCacheHelper { private const string _contentKey = "CustomCronJobListKey"; 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); } } }