using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace learun.cache
{
///
/// 版 本 EasyCode EC管理后台
/// Copyright (c) 2019-present EC管理有限公司
/// 创建人:tobin
/// 日 期:2019.09.09
/// 描 述:定义缓存接口
///
public interface ICache
{
#region Key-Value
///
/// 读取缓存
///
/// 键
/// 指定库ID,默认0
///
T Read(string cacheKey, int dbId = 0) where T : class;
///
/// 写入缓存
///
/// 对象数据
/// 键
/// 指定库ID,默认0
void Write(string cacheKey, T value, int dbId = 0) where T : class;
///
/// 写入缓存
///
/// 对象数据
/// 键
/// 到期时间
/// 指定库ID,默认0
void Write(string cacheKey, T value, TimeSpan timeSpan, int dbId = 0) where T : class;
///
/// 移除指定数据缓存
///
/// 键
/// 指定库ID,默认0
void Remove(string cacheKey, int dbId = 0);
///
/// 移除全部缓存
///
void RemoveAll(int dbId = 0);
#endregion Key-Value
#region List
#region 同步方法
///
/// 移除指定ListId的内部List的值
///
///
///
/// 指定库ID,默认0
void ListRemove(string cacheKey, T value, int dbId = 0) where T : class;
///
/// 获取指定key的List
///
///
/// 指定库ID,默认0
///
List ListRange(string cacheKey, int dbId = 0) where T : class;
///
/// 入队
///
///
///
/// 指定库ID,默认0
void ListRightPush(string cacheKey, T value, int dbId = 0) where T : class;
///
/// 出队
///
///
///
/// 指定库ID,默认0
///
T ListRightPop(string cacheKey, int dbId = 0) where T : class;
///
/// 入栈
///
///
///
///
/// 指定库ID,默认0
void ListLeftPush(string cacheKey, T value, int dbId = 0) where T : class;
///
/// 出栈
///
///
///
/// 指定库ID,默认0
///
T ListLeftPop(string cacheKey, int dbId = 0) where T : class;
///
/// 获取集合中的数量
///
///
/// 指定库ID,默认0
///
long ListLength(string cacheKey, int dbId = 0);
#endregion 同步方法
#endregion List
#region Key-Value 异步
///
/// 读取缓存
///
/// 键
/// 指定库ID,默认0
///
Task ReadAsync(string cacheKey, int dbId = 0) where T : class;
///
/// 写入缓存
///
/// 对象数据
/// 键
/// 指定库ID,默认0
Task WriteAsync(string cacheKey, T value, int dbId = 0) where T : class;
///
/// 写入缓存
///
/// 对象数据
/// 键
/// 到期时间
/// 指定库ID,默认0
Task WriteAsync(string cacheKey, T value, TimeSpan timeSpan, int dbId = 0) where T : class;
///
/// 移除指定数据缓存
///
/// 键
/// 指定库ID,默认0
Task RemoveAsync(string cacheKey, int dbId = 0);
///
/// 移除全部缓存
///
/// 指定库ID,默认0
Task RemoveAllAsync(int dbId = 0);
#endregion Key-Value 异步
}
}