using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Znyc.Cloudcar.Admin.Commons.Cache
{
///
/// 缓存服务接口
///
public interface ICacheService
{
#region 验证缓存项是否存在
///
/// 验证缓存项是否存在
///
/// 缓存Key
///
bool Exists(string key);
#endregion 验证缓存项是否存在
#region 添加缓存
///
/// 添加缓存
///
/// 缓存Key
/// 缓存Value
///
bool Add(string key, object value);
///
/// 添加缓存
///
/// 缓存Key
/// 缓存Value
/// 滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)
/// 绝对过期时长
///
bool Add(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte);
///
/// 添加缓存
///
/// 缓存Key
/// 缓存Value
/// 缓存时长
/// 是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)
///
bool Add(string key, object value, TimeSpan expiresIn, bool isSliding = false);
///
///
///
///
///
///
Task HashSetAsync(string key, string filed, object value);
///
/// 添加缓存
///
/// 缓存Key
/// 缓存Value
///
Task AddAsync(string key, object value);
///
/// /
///
///
///
///
///
///
Task AddAsync(string key, object value, TimeSpan expiresIn, bool isSliding = false);
#endregion 添加缓存
#region 删除缓存
///
/// 删除缓存
///
/// 缓存Key
///
bool Remove(string key);
///
/// 批量删除缓存
///
/// 缓存Key集合
///
void RemoveAll(IEnumerable keys);
///
/// 使用通配符找出所有的key然后逐个删除
///
/// 通配符
void RemoveByPattern(string pattern);
///
/// 删除所有缓存
///
void RemoveCacheAll();
///
/// 删除缓存
///
/// 缓存Key
///
Task RemoveAsync(string key);
#endregion 删除缓存
#region 获取缓存
///
/// 获取缓存
///
/// 缓存Key
///
T Get(string key) where T : class;
///
/// 获取缓存
///
/// 缓存Key
///
object Get(string key);
///
/// 获取缓存集合
///
/// 缓存Key集合
///
IDictionary GetAll(IEnumerable keys);
#endregion 获取缓存
#region 修改缓存
///
/// 修改缓存
///
/// 缓存Key
/// 新的缓存Value
///
bool Replace(string key, object value);
///
/// 修改缓存
///
/// 缓存Key
/// 新的缓存Value
/// 滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)
/// 绝对过期时长
///
bool Replace(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte);
///
/// 修改缓存
///
/// 缓存Key
/// 新的缓存Value
/// 缓存时长
/// 是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)
///
bool Replace(string key, object value, TimeSpan expiresIn, bool isSliding = false);
#endregion 修改缓存
#region Hash
///
///
///
///
///
///
bool HSet(string key, string filed, object value);
///
///
///
///
///
///
Task HSetAsync(string key, string filed, object value);
///
///
///
///
///
Task HMSetAsync(string key, object[] value);
///
///
///
///
///
bool HMSet(string key, object[] value);
///
///
///
///
///
string[] HMGet(string key, string[] filed);
///
///
///
///
///
Task HMGetAsync(string key, string filed);
///
///
///
///
///
long HDel(string key, string[] filed);
///
///
///
///
///
Task HDelAsync(string key, string filed);
///
///
///
///
///
bool HExists(string key, string filed);
///
///
///
///
///
Task HExistsAsync(string key, string filed);
///
/// 自增
///
///
///
///
Task HIncrByAsync(string key, string filed);
///
/// 自增
///
///
///
///
long HIncrBy(string key, string filed);
///
/// 获取所有
///
///
///
Task> HGetAllAsync(string key);
///
/// 获取所有
///
///
///
Dictionary HGetAll(string key);
///
///
///
///
///
Task HGetAsync(string key, string filed);
///
/// 设置一个键值对(不存在,则创建;否则,修改)
///
///
///
///
///
Task HSetNxAsync(string key, string filed, object value);
///
/// 设置一个键值对(不存在,则创建;否则,修改)
///
///
///
///
///
bool HSetNx(string key, string filed, object value);
#endregion
}
}