using JiShe.CollectBus.Common.Models; using JiShe.CollectBus.IotSystems.Ammeters; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace JiShe.CollectBus.Application.Contracts { /// /// 数据缓存服务接口 /// public interface IRedisDataCacheService { /// /// 单个添加数据 /// /// /// 主数据存储Hash缓存Key /// Set索引缓存Key /// ZSET索引缓存Key /// 待缓存数据 /// Task InsertDataAsync( string redisHashCacheKey, string redisSetIndexCacheKey, string redisZSetScoresIndexCacheKey, T data) where T : DeviceCacheBasicModel; /// /// 批量添加数据 /// /// /// 主数据存储Hash缓存Key /// Set索引缓存Key /// ZSET索引缓存Key /// 设备缓存信息 /// 待缓存数据集合 /// Task BatchInsertDataAsync( string redisHashCacheKey, string redisSetIndexCacheKey, string redisZSetScoresIndexCacheKey, string redisDeviceInfoHashCacheKey, IEnumerable items) where T : DeviceCacheBasicModel; /// /// 批量添加数据 /// /// /// Set索引缓存Key /// 设备缓存信息 /// 待缓存数据集合 /// Task BatchInsertDataAsync2( string redisSetIndexCacheKey, string redisDeviceInfoHashCacheKey, Dictionary> items) where T : DeviceCacheBasicModel; /// /// 删除缓存信息 /// /// /// 主数据存储Hash缓存Key /// Set索引缓存Key /// ZSET索引缓存Key /// 已缓存数据 /// Task RemoveCacheDataAsync( string redisHashCacheKey, string redisSetIndexCacheKey, string redisZSetScoresIndexCacheKey, T data) where T : DeviceCacheBasicModel; /// /// 修改缓存信息,映射关系未发生改变 /// /// /// 主数据存储Hash缓存Key /// Set索引缓存Key /// ZSET索引缓存Key /// 待修改缓存数据 /// Task ModifyDataAsync( string redisHashCacheKey, string redisSetIndexCacheKey, string redisZSetScoresIndexCacheKey, T newData) where T : DeviceCacheBasicModel; /// /// 修改缓存信息,映射关系已改变 /// /// /// 主数据存储Hash缓存Key /// Set索引缓存Key /// 旧的映射关系 /// ZSET索引缓存Key /// 待修改缓存数据 /// Task ModifyDataAsync( string redisHashCacheKey, string redisSetIndexCacheKey, string oldMemberId, string redisZSetScoresIndexCacheKey, T newData) where T : DeviceCacheBasicModel; /// /// 通过集中器与表计信息排序索引获取数据 /// /// /// 主数据存储Hash缓存Key /// ZSET索引缓存Key /// 分页尺寸 /// 最后一个索引 /// 最后一个唯一标识 /// 排序方式 /// Task> GetPagedData( string redisHashCacheKey, string redisZSetScoresIndexCacheKey, IEnumerable focusIds, int pageSize = 10, decimal? lastScore = null, string lastMember = null, bool descending = true) where T : DeviceCacheBasicModel; /// /// 通过集中器与表计信息排序索引获取数据 /// /// /// 主数据存储Hash缓存Key /// ZSET索引缓存Key /// ZSET索引的原始数据,例如集中地址和点位的组合 /// 分页尺寸 /// 最后一个索引 /// 最后一个唯一标识 /// 排序方式 /// Task> GetSingleData( string redisHashCacheKey, string redisZSetScoresIndexCacheKey, string scoreValueRawData, int pageSize = 10, decimal? lastScore = null, string lastMember = null, bool descending = true) where T : DeviceCacheBasicModel; /// /// 通过ZSET索引获取数据,支持10万级别数据处理,控制在13秒以内。 /// /// /// 主数据存储Hash缓存Key /// ZSET索引缓存Key /// 分页尺寸 /// 最后一个索引 /// 最后一个唯一标识 /// 排序方式 /// Task> GetAllPagedData( string redisHashCacheKey, string redisZSetScoresIndexCacheKey, int pageSize = 1000, decimal? lastScore = null, string lastMember = null, bool descending = true) where T : DeviceCacheBasicModel; ///// ///// 游标分页查询 ///// ///// 排序索引ZSET缓存Key ///// 分页数量 ///// 开始索引 ///// 开始唯一标识 ///// 排序方式 ///// //Task<(List Members, bool HasNext)> GetPagedMembers( // string redisZSetScoresIndexCacheKey, // int pageSize, // decimal? startScore, // string excludeMember, // bool descending); ///// ///// 批量获取指定分页的数据 ///// ///// ///// Hash表缓存key ///// Hash表字段集合 ///// //Task> BatchGetData( // string redisHashCacheKey, // IEnumerable members) // where T : DeviceCacheBasicModel; ///// ///// 获取下一页游标 ///// ///// 排序索引ZSET缓存Key ///// 最后一个唯一标识 ///// 排序方式 ///// //Task GetNextScore( // string redisZSetScoresIndexCacheKey, // string lastMember, // bool descending); } }