using StackExchange.Redis; using System; using System.Collections.Generic; using System.Text; namespace Nirvana.Common { public interface ICache { /// /// 缓存过期时间 /// int TimeOut { set; get; } /// /// 获得指定键的缓存值 /// /// 缓存键 /// 缓存值 object Get(string key); /// /// 获得指定键的缓存值 /// T Get(string key); T stringGet(string key); /// /// 从缓存中移除指定键的缓存值 /// /// 缓存键 void Remove(string key); /// /// 清空所有缓存对象 /// //void Clear(); /// /// 将指定键的对象添加到缓存中 /// /// 缓存键 /// 缓存值 void Insert(string key, object data); /// /// 将指定键的对象添加到缓存中 /// /// 缓存键 /// 缓存值 void Insert(string key, T data); /// /// 将指定键的对象添加到缓存中,并指定过期时间 /// /// 缓存键 /// 缓存值 /// 缓存过期时间(秒钟) void Insert(string key, object data, int cacheTime); /// /// 将指定键的对象添加到缓存中,并指定过期时间 /// /// 缓存键 /// 缓存值 /// 缓存过期时间(秒钟) void Insert(string key, T data, int cacheTime); /// /// 将指定键的对象添加到缓存中,并指定过期时间 /// /// 缓存键 /// 缓存值 /// 缓存过期时间 void Insert(string key, object data, DateTime cacheTime); /// /// 将指定键的对象添加到缓存中,并指定过期时间 /// /// 缓存键 /// 缓存值 /// 缓存过期时间 void Insert(string key, T data, DateTime cacheTime); /// /// 判断key是否存在 /// bool Exists(string key); /// /// 判断该字段是否存在hash中 /// /// /// /// bool HashExists(string key, string field); /// /// 从 hash 中移除指定字段 /// /// /// /// bool HashDelete(string redisKey, string hashField); /// /// 从 hash 中移除指定字段 /// /// /// /// long HashDelete(string redisKey, IEnumerable hashField); /// /// 在 hash 设定值 /// /// /// /// bool HashSet(string redisKey, string hashField, string value); /// /// 在 hash 中设定值 /// /// /// void HashSet(string redisKey, IEnumerable hashFields); /// /// 在 hash 中获取值 /// /// /// /// RedisValue HashGet(string redisKey, string hashField); /// /// 在 hash 中获取值 /// /// /// /// /// RedisValue[] HashGet(string redisKey, RedisValue[] hashField, string value); IEnumerable HashKeys(string redisKey); RedisValue[] HashValues(string redisKey); } }