You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PLT-PDA/Admin.Core.Extensions/Redis/IRedisBasketRepository.cs

210 lines
7.0 KiB
C#

1 year ago
using Admin.Core.Common;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Admin.Core.Extensions
{
/// <summary>
/// Redis缓存接口
/// </summary>
public interface IRedisBasketRepository
{
/// <summary>
/// 获取服务基础信息
/// </summary>
RedisBaseView GetBaseInfo();
/// <summary>
/// 缓存监控
/// </summary>
List<RedisKeyView> GetAllKes();
/// <summary>
/// 节点状态
/// </summary>
/// <returns></returns>
List<PointStatus> GetPointStatus();
/// <summary>
/// 获取 Reids 缓存值
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
Task<string> GetValue(string key);
/// <summary>
/// 获取值,并序列化
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
Task<TEntity> Get<TEntity>(string key);
/// <summary>
/// 保存
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="timeSpan">缓存过期时间,单位:分钟</param>
/// <returns></returns>
Task<bool> SetStr(string key, string value, int timeSpan = 0);
/// <summary>
/// 保存-永不过期
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="timeSpan">缓存过期时间,单位:分钟</param>
/// <returns></returns>
Task<bool> SetStrL(string key, string value);
/// <summary>
/// 保存
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="timeSpan">缓存过期时间,单位:分钟</param>
/// <returns></returns>
Task<bool> SetObj(string key, object value, int timeSpan = 0);
/// <summary>
/// 保存-永不过期
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="timeSpan">缓存过期时间,单位:分钟</param>
/// <returns></returns>
Task<bool> SetObjL(string key, object value);
/// <summary>
/// 判断是否存在
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
Task<bool> Exist(string key);
/// <summary>
/// 移除某一个缓存值
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
Task<bool> Remove(string key);
/// <summary>
/// 全部清除
/// </summary>
/// <returns></returns>
Task Clear();
/// <summary>
/// 根据key获取RedisValue
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="redisKey"></param>
/// <returns></returns>
Task<RedisValue[]> ListRangeAsync(string redisKey);
/// <summary>
/// 在列表头部插入值。如果键不存在,先创建再插入值
/// </summary>
/// <param name="redisKey"></param>
/// <param name="redisValue"></param>
/// <returns></returns>
Task<long> ListLeftPushAsync(string redisKey, string redisValue, int db = -1);
/// <summary>
/// 在列表尾部插入值。如果键不存在,先创建再插入值
/// </summary>
/// <param name="redisKey"></param>
/// <param name="redisValue"></param>
/// <returns></returns>
Task<long> ListRightPushAsync(string redisKey, string redisValue, int db = -1);
/// <summary>
/// 在列表尾部插入数组集合。如果键不存在,先创建再插入值
/// </summary>
/// <param name="redisKey"></param>
/// <param name="redisValue"></param>
/// <returns></returns>
Task<long> ListRightPushAsync(string redisKey, IEnumerable<string> redisValue, int db = -1);
/// <summary>
/// 移除并返回存储在该键列表的第一个元素 反序列化
/// </summary>
/// <param name="redisKey"></param>
/// <returns></returns>
Task<T> ListLeftPopAsync<T>(string redisKey, int db = -1) where T : class;
/// <summary>
/// 移除并返回存储在该键列表的最后一个元素 反序列化
/// 只能是对象集合
/// </summary>
/// <param name="redisKey"></param>
/// <returns></returns>
Task<T> ListRightPopAsync<T>(string redisKey, int db = -1) where T : class;
/// <summary>
/// 移除并返回存储在该键列表的第一个元素
/// </summary>
/// <param name="redisKey"></param>
/// <param name="db"></param>
/// <returns></returns>
Task<string> ListLeftPopAsync(string redisKey, int db = -1);
/// <summary>
/// 移除并返回存储在该键列表的最后一个元素
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="redisKey"></param>
/// <param name="db"></param>
/// <returns></returns>
Task<string> ListRightPopAsync(string redisKey, int db = -1);
/// <summary>
/// 列表长度
/// </summary>
/// <param name="redisKey"></param>
/// <param name="db"></param>
/// <returns></returns>
Task<long> ListLengthAsync(string redisKey, int db = -1);
/// <summary>
/// 返回在该列表上键所对应的元素
/// </summary>
/// <param name="redisKey"></param>
/// <returns></returns>
Task<IEnumerable<string>> ListRangeAsync(string redisKey, int db = -1);
/// <summary>
/// 根据索引获取指定位置数据
/// </summary>
/// <param name="redisKey"></param>
/// <param name="start"></param>
/// <param name="stop"></param>
/// <param name="db"></param>
/// <returns></returns>
Task<IEnumerable<string>> ListRangeAsync(string redisKey, int start, int stop, int db = -1);
/// <summary>
/// 删除List中的元素 并返回删除的个数
/// </summary>
/// <param name="redisKey">key</param>
/// <param name="redisValue">元素</param>
/// <param name="type">大于零 : 从表头开始向表尾搜索,小于零 : 从表尾开始向表头搜索,等于零:移除表中所有与 VALUE 相等的值</param>
/// <param name="db"></param>
/// <returns></returns>
Task<long> ListDelRangeAsync(string redisKey, string redisValue, long type = 0, int db = -1);
/// <summary>
/// 清空List
/// </summary>
/// <param name="redisKey"></param>
/// <param name="db"></param>
Task ListClearAsync(string redisKey, int db = -1);
}
}