From 73fbcaac2263d48593b53f781a14871aacedeb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=81=B0=E7=81=B0?= Date: Sat, 16 Apr 2022 13:26:06 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91redis?= =?UTF-8?q?=E4=BB=93=E5=82=A8=E5=A2=9E=E5=8A=A0=E6=9C=89=E5=BA=8F=E9=9B=86?= =?UTF-8?q?=E5=90=88=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=84=9F=E8=B0=A2=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E9=99=8C=E5=B0=8F=E5=8C=97=E4=BC=98=E5=8C=96=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RedisCache/IRedisOperationRepository.cs | 44 +++++++++++++- .../RedisCache/RedisOperationRepository.cs | 58 ++++++++++++++++++- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/CoreCms.Net.Caching/AutoMate/RedisCache/IRedisOperationRepository.cs b/CoreCms.Net.Caching/AutoMate/RedisCache/IRedisOperationRepository.cs index 143a2d63..1b586f27 100644 --- a/CoreCms.Net.Caching/AutoMate/RedisCache/IRedisOperationRepository.cs +++ b/CoreCms.Net.Caching/AutoMate/RedisCache/IRedisOperationRepository.cs @@ -131,13 +131,55 @@ namespace CoreCms.Net.Caching.AutoMate.RedisCache Task ListClearAsync(string redisKey); + /// - /// 有序集合/定时任务延迟队列用的多 + /// 有序集合/定时任务延迟队列用的多(直接传分钟) /// /// key /// 元素 /// 分数 Task SortedSetAddAsync(string redisKey, string redisValue, double score); + + /// + /// 有序集合/定时任务延迟队列用的多(直接传时间) + /// + /// key + /// 元素 + /// 时间 + Task SortedSetAddAsync(string redisKey, string redisValue, DateTime dt); + + #region 会员陌小北(QQ:1078350533) 添加的 几个有序集合功能 + + /// + /// 返回有序列表里的数据 + /// + /// RedisKey + /// 0 是第一个 + /// 最大分数值 + /// + Task> SortedSetRangeByRankAsync(string redisKey, int start, int stop); + + /// + /// 移出序列表里的指定范围数量 + /// + /// RedisKey + /// 0 是第一个 + /// 最大分数值 + /// + Task SortedSetRemoveRangeByRankAsync(string redisKey, int start, int stop); + + + /// + /// 返回有序列表里的指定范围数量 + /// + /// RedisKey + /// 0 是第一个 + /// 最大分数值 + /// + Task SortedSetLengthAsync(string redisKey, int start, int stop); + + #endregion + } } diff --git a/CoreCms.Net.Caching/AutoMate/RedisCache/RedisOperationRepository.cs b/CoreCms.Net.Caching/AutoMate/RedisCache/RedisOperationRepository.cs index d70ef80a..42d23b3e 100644 --- a/CoreCms.Net.Caching/AutoMate/RedisCache/RedisOperationRepository.cs +++ b/CoreCms.Net.Caching/AutoMate/RedisCache/RedisOperationRepository.cs @@ -229,7 +229,7 @@ namespace CoreCms.Net.Caching.AutoMate.RedisCache /// - /// 有序集合/定时任务延迟队列用的多 + /// 有序集合/定时任务延迟队列用的多(直接传分钟) /// /// key /// 元素 @@ -239,5 +239,61 @@ namespace CoreCms.Net.Caching.AutoMate.RedisCache await _database.SortedSetAddAsync(redisKey, redisValue, score); } + /// + /// 有序集合/定时任务延迟队列用的多(直接传时间) + /// + /// key + /// 元素 + /// 时间 + public async Task SortedSetAddAsync(string redisKey, string redisValue, DateTime dt) + { + var score = (dt.ToUniversalTime().Ticks - 621355968000000000) / 10000000; + await _database.SortedSetAddAsync(redisKey, redisValue, score); + } + + #region 会员陌小北(QQ:1078350533) 添加的 几个有序集合功能 + + /// + /// 返回有序列表里的数据 + /// + /// RedisKey + /// 0 是第一个 + /// 最大分数值 + /// + public async Task> SortedSetRangeByRankAsync(string redisKey, int start, int stop) + { + var result = await _database.SortedSetRangeByRankAsync(redisKey, start, stop); + + return result.Select(o => o.ToString()); + + } + + /// + /// 移出序列表里的指定范围数量 + /// + /// RedisKey + /// 0 是第一个 + /// 最大分数值 + /// + public async Task SortedSetRemoveRangeByRankAsync(string redisKey, int start, int stop) + { + return await _database.SortedSetRemoveRangeByRankAsync(redisKey, start, stop); + } + + /// + /// 返回有序列表里的指定范围数量 + /// + /// RedisKey + /// 0 是第一个 + /// 最大分数值 + /// + public async Task SortedSetLengthAsync(string redisKey, int start, int stop) + { + return await _database.SortedSetLengthAsync(redisKey, start, stop); + + } + + #endregion 会员陌小北(QQ:1078350533) 添加的 几个有序集合功能 + } }