duheng
2024-07-10 2a41fffc9f962999ba163c3b471873b6b96f05bc
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
namespace HStation.Service.Xhs
{
    /// <summary>
    /// 缓存辅助类
    /// </summary>
    internal class CacheHelper
    {
        private const string _cacheKeyPrefix = "Xhs";//缓存键前缀
 
        /// <summary>
        /// 获取缓存键
        /// </summary>
        public static string GetCacheKey(string keyContent)
        {
            return MemoryCacheKeyHelper.GetKey(MemoryCacheKey.ServiceLevel, MemoryCacheKey.Module, $"*{_cacheKeyPrefix}*_{keyContent}");
        }
 
        /// <summary>
        /// 清除全部
        /// </summary>
        public static void Clear()
        {
            Yw.MemoryCacheHelper.Remove((key) =>
            {
                var prefix = MemoryCacheKeyHelper.GetKey(MemoryCacheKey.ServiceLevel, MemoryCacheKey.Module, $"*{_cacheKeyPrefix}*");
                return key.StartsWith(prefix);
            });
        }
 
 
 
 
    }
}