using System; using StackExchange.Redis; namespace BLL { /// /// 接口 /// public interface ICache { /// /// 缓存过期时间 /// int TimeOut { set; get; } /// /// 获得指定键的缓存值 /// /// 缓存键 /// 缓存值 object Get(string key); /// /// 获得指定键的缓存值 /// T Get(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); /// /// 右侧入队 /// /// /// /// long EnqueueListRightPush(RedisKey queueName, RedisValue redisValue); /// /// 左侧入队 /// /// /// /// long EnqueueListLeftPush(RedisKey queueName, RedisValue redisvalue); /// /// 获取队列长度 /// /// /// long EnqueueListLength(RedisKey queueName); /// /// 左侧出队 /// /// /// string DequeueListPopLeft(RedisKey queueName); /// /// 右侧出队 /// /// /// string DequeueListPopRight(RedisKey queueName); /// /// 分布式加锁 /// /// 键 /// 值 /// 过期时间 /// bool LockTake(string key, string data, TimeSpan seconds, int db = 0); /// /// 解锁 /// /// 键 /// 值 /// bool LockRelease(string key, string data, int db = -1); } }