using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YY.Admin.Core { public interface ISysCacheService { /// /// 申请分布式锁 /// IDisposable? BeginCacheLock(string key, int msTimeout = 500, int msExpire = 10000, bool throwOnFailure = true); /// /// 获取缓存键名集合 /// List GetKeyList(); /// /// 增加缓存 /// bool Set(string key, object value); /// /// 增加缓存并设置过期时间 /// bool Set(string key, object value, TimeSpan expire); /// /// 异步获取或添加缓存(无参数) /// Task AdGetAsync(string cacheName, Func> del, TimeSpan? expiry = default) where TR : class; /// /// 异步获取或添加缓存(1个参数) /// Task AdGetAsync(string cacheName, Func> del, T1 t1, TimeSpan? expiry = default) where TR : class; /// /// 异步获取或添加缓存(2个参数) /// Task AdGetAsync(string cacheName, Func> del, T1 t1, T2 t2, TimeSpan? expiry = default) where TR : class; /// /// 异步获取或添加缓存(3个参数) /// Task AdGetAsync(string cacheName, Func> del, T1 t1, T2 t2, T3 t3, TimeSpan? expiry = default) where TR : class; /// /// 获取缓存(1个参数) /// T Get(string cacheName, object t1); /// /// 获取缓存(2个参数) /// T Get(string cacheName, object t1, object t2); /// /// 获取缓存(3个参数) /// T Get(string cacheName, object t1, object t2, object t3); /// /// 获取缓存的剩余生存时间 /// TimeSpan GetExpire(string key); /// /// 获取缓存 /// T Get(string key); /// /// 删除缓存 /// int Remove(string key); /// /// 清空所有缓存 /// void Clear(); /// /// 检查缓存是否存在 /// bool ExistKey(string key); /// /// 根据键名前缀删除缓存 /// int RemoveByPrefixKey(string prefixKey); /// /// 根据键名前缀获取键名集合 /// List GetKeysByPrefixKey(string prefixKey); /// /// 获取缓存值(原始对象) /// object GetValue(string key); /// /// 获取或添加缓存(在数据不存在时执行委托请求数据) /// T GetOrAdd(string key, Func callback, int expire = -1); /// /// 获取Hash缓存字典 /// IDictionary GetHashMap(string key); /// /// 批量添加Hash值 /// bool HashSet(string key, Dictionary dic); /// /// 添加一条Hash值 /// void HashAdd(string key, string hashKey, T value); /// /// 添加或更新一条Hash值 /// void HashAddOrUpdate(string key, string hashKey, T value); /// /// 获取多条Hash值 /// List HashGet(string key, params string[] fields); /// /// 获取一条Hash值 /// T HashGetOne(string key, string field); /// /// 根据KEY获取所有Hash值 /// IDictionary HashGetAll(string key); /// /// 删除Hash值 /// int HashDel(string key, params string[] fields); } }