// Admin.NET 项目的版æƒã€å•†æ ‡ã€ä¸“利和其他相关æƒåˆ©å‡å—ç›¸åº”æ³•å¾‹æ³•è§„çš„ä¿æŠ¤ã€‚ä½¿ç”¨æœ¬é¡¹ç›®åº”éµå®ˆç›¸å…³æ³•律法规和许å¯è¯çš„è¦æ±‚。 // // 本项目主è¦éµå¾ª MIT 许å¯è¯å’Œ Apache 许å¯è¯ï¼ˆç‰ˆæœ¬ 2.0)进行分å‘和使用。许å¯è¯ä½äºŽæºä»£ç æ ‘æ ¹ç›®å½•ä¸çš„ LICENSE-MIT å’Œ LICENSE-APACHE 文件。 // // ä¸å¾—利用本项目从事å±å®³å›½å®¶å®‰å…¨ã€æ‰°ä¹±ç¤¾ä¼šç§©åºã€ä¾µçŠ¯ä»–äººåˆæ³•æƒç›Šç‰æ³•å¾‹æ³•è§„ç¦æ¢çš„æ´»åЍï¼ä»»ä½•基于本项目二次开å‘è€Œäº§ç”Ÿçš„ä¸€åˆ‡æ³•å¾‹çº çº·å’Œè´£ä»»ï¼Œæˆ‘ä»¬ä¸æ‰¿æ‹…ä»»ä½•è´£ä»»ï¼ namespace Admin.NET.Core; /// <summary> /// SqlSugaräºŒçº§ç¼“å˜ /// </summary> public class SqlSugarCache : ICacheService { /// <summary> /// ç³»ç»Ÿç¼“å˜æœåŠ¡ /// </summary> private static readonly SysCacheService _cache = App.GetRequiredService<SysCacheService>(); public void Add<V>(string key, V value) { _cache.Set($"{CacheConst.SqlSugar}{key}", value); } public void Add<V>(string key, V value, int cacheDurationInSeconds) { _cache.Set($"{CacheConst.SqlSugar}{key}", value, TimeSpan.FromSeconds(cacheDurationInSeconds)); } public bool ContainsKey<V>(string key) { return _cache.ExistKey($"{CacheConst.SqlSugar}{key}"); } public V Get<V>(string key) { return _cache.Get<V>($"{CacheConst.SqlSugar}{key}"); } public IEnumerable<string> GetAllKey<V>() { return _cache.GetKeysByPrefixKey(CacheConst.SqlSugar); } public V GetOrCreate<V>(string key, Func<V> create, int cacheDurationInSeconds = int.MaxValue) { return _cache.GetOrAdd<V>($"{CacheConst.SqlSugar}{key}", (cacheKey) => { return create(); }, cacheDurationInSeconds); } public void Remove<V>(string key) { _cache.Remove(key); // SqlSugar调用Remove方法时,keyä¸å·²åŒ…å«äº†CacheConst.SqlSugarå‰ç¼€ } }