duheng
2024-08-21 6c88a90d2330a27c0052a22538f6ebd6200faae7
Service/HStation.Service.Assets.Core/05-service/00-core/02-cache/CacheHelper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,30 @@
namespace HStation.Service
{
    /// <summary>
    /// ç¼“存辅助类
    /// </summary>
    internal class CacheHelper
    {
        private const string _cacheKeyPrefix = "Assets";//缓存键前缀
        /// <summary>
        /// èŽ·å–ç¼“å­˜é”®
        /// </summary>
        public static string GetCacheKey(string keyContent)
        {
            return MemoryCacheKeyHelper.GetKey(HStation.Assets.MemoryCacheKey.ServiceLevel, HStation.Assets.MemoryCacheKey.Module, $"*{_cacheKeyPrefix}*_{keyContent}");
        }
        /// <summary>
        /// æ¸…除全部
        /// </summary>
        public static void Clear()
        {
            Yw.MemoryCacheHelper.Remove((key) =>
            {
                var prefix = MemoryCacheKeyHelper.GetKey(HStation.Assets.MemoryCacheKey.ServiceLevel, HStation.Assets.MemoryCacheKey.Module, $"*{_cacheKeyPrefix}*");
                return key.StartsWith(prefix);
            });
        }
    }
}