using System; using System.Collections.Generic; using System.Threading.Tasks; using static CSRedis.CSRedisClient; namespace Znyc.Dispatching.Core.Cache { /// /// 缓存接口 /// public interface IRedisCache { /// /// 用于在 key 存在时删除 key /// /// 键 long Del(params string[] key); /// /// 用于在 key 存在时删除 key /// /// 键 /// Task DelAsync(params string[] key); /// /// 用于在 key 模板存在时删除 /// /// key模板 /// Task DelByPatternAsync(string pattern); /// /// 检查给定 key 是否存在 /// /// 键 /// bool Exists(string key); /// /// 检查给定 key 是否存在 /// /// 键 /// Task ExistsAsync(string key); /// /// 获取指定 key 的值 /// /// 键 /// string Get(string key); /// /// 获取指定 key 的值 /// /// byte[] 或其他类型 /// 键 /// T Get(string key); /// /// 获取指定 key 的值 /// /// 键 /// Task GetAsync(string key); /// /// 获取指定 key 的值 /// /// byte[] 或其他类型 /// 键 /// Task GetAsync(string key); /// /// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象 /// /// 键 /// 值 bool Set(string key, object value); /// /// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象 /// /// 键 /// 值 /// 有效期 bool Set(string key, object value, TimeSpan expire); /// /// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象 /// /// 键 /// 值 /// Task SetAsync(string key, object value); /// /// 设置指定 key 的值,所有写入参数object都支持string | byte[] | 数值 | 对象 /// /// 键 /// 值 /// 有效期 /// Task SetAsync(string key, object value, TimeSpan expire); /// /// 获取所有缓存 /// /// List GetAllKeys(); /// /// 缓存壳 /// /// /// /// /// /// T CacheShell(string key, int timeoutSeconds, Func getDataAsync); /// /// 缓存壳 /// /// /// /// /// /// Task CacheShellAsync(string key, int timeoutSeconds, Func> getDataAsync); /// /// 发布 /// /// /// /// Task PublishAsync(string channel, string message); /// /// 订阅 /// /// /// SubscribeObject Subscribe(params (string, Action)[] channels); } }