using System; using System.Collections.Generic; namespace OS.Common.Modules.CacheModule { /// /// /// public interface ICache { /// /// 添加缓存,已存在不更新 /// /// 添加缓存对象类型 /// 添加对象的key /// 值 /// 相对过期的TimeSpan 如果使用固定时间 =TimeSpan.Zero /// 绝对过期时间 /// 是否添加成功 bool Add(string key, T obj, TimeSpan slidingExpiration, DateTime? absoluteExpiration = null); /// /// 添加缓存,如果存在则更新 /// /// 添加缓存对象类型 /// 添加对象的key /// 值 /// 相对过期的TimeSpan 如果使用固定时间 =TimeSpan.Zero /// 绝对过期时间 /// 是否添加成功 bool AddOrUpdate(string key, T obj, TimeSpan slidingExpiration, DateTime? absoluteExpiration = null); /// /// 获取缓存对象 /// /// 获取缓存对象类型 /// key /// 获取指定key对应的值 T Get(string key); /// /// 移除缓存对象 /// /// /// 是否成功 bool Remove(string key); /// /// 判断是否存在缓存对象 /// /// key值 /// bool Contains(string key); } }