ICacheService二级缓存接口建议提供一个异步接口。 返回
SqlSugar
107
悬赏:0 飞吻
项目中用了StackExchange.Redis这个框架,这个框架的的同步方法经常偶发性出现time out的错误(线程饥饿导致的问题),StackExchange.Redis需要用异步方法来解决这个问题,但是咱们提供的这个ICacheService没有提供异步方法,大佬能升级一下么。
大概能提供一个类似的下面这个接口,不知道我的建议是否可行?
public interface IAsyncCacheService
{
Task Add<V>(string key, V value);
Task Add<V>(string key, V value, int cacheDurationInSeconds);
Task<bool> ContainsKey<V>(string key);
Task<V> Get<V>(string key);
Task<IEnumerable<string>> GetAllKey<V>();
Task Remove<V>(string key);
Task<V> GetOrCreate<V>(string cacheKey, Func<V> create, int cacheDurationInSeconds = int.MaxValue);
}顺便感谢官方大佬开发一个那么好的框架。