ningshuxia
2024-04-25 769413fc5ff52240f001fb4bcfcca21728fb275a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using Yw;
 
namespace IStation.Service
{
    /// <summary>
    /// MonitorPointGroup缓存辅助类
    /// </summary>
    internal class MonitorPointGroupCacheHelper
    {
        private const string _contentKey = "MonitorPointGroupListKey";
 
        private static string GetCacheKey()
        {
            var contentKey = string.Format("{0}", _contentKey);
            return CacheHelper.GetCacheKey(contentKey);
        }
 
        /// <summary>
        /// 设置缓存
        /// </summary>
        public static void Set(List<Model.MonitorPointGroup> list, int Minites = 30, int RandomSeconds = 0)
        {
            var cacheKey = GetCacheKey();
            MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds);
        }
 
        /// <summary>
        /// 查询缓存
        /// </summary>
        public static List<Model.MonitorPointGroup> Get()
        {
            var cacheKey = GetCacheKey();
            return MemoryCacheHelper.Get<List<Model.MonitorPointGroup>>(cacheKey);
        }
 
        /// <summary>
        /// 查询设置缓存
        /// </summary>
        public static List<Model.MonitorPointGroup> GetSet(Func<List<Model.MonitorPointGroup>> 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));
            });
        }
 
 
    }
}