优化代码

This commit is contained in:
ChenYi 2025-04-17 09:10:01 +08:00
parent cadb69f4b9
commit 4737c5b53d

View File

@ -7,6 +7,7 @@ using JiShe.CollectBus.Common.Models;
using JiShe.CollectBus.FreeRedisProvider;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -385,16 +386,18 @@ namespace JiShe.CollectBus.RedisDataCache
bool descending = true)
where T : DeviceCacheBasicModel
{
// 参数校验
if (string.IsNullOrWhiteSpace(redisHashCacheKey) ||
string.IsNullOrWhiteSpace(redisZSetScoresIndexCacheKey))
// 参数校验增强
if (string.IsNullOrWhiteSpace(redisHashCacheKey) || string.IsNullOrWhiteSpace(redisZSetScoresIndexCacheKey))
{
_logger.LogError("参数异常: HashKey或ZSetKey为空");
_logger.LogError($"{nameof(GetAllPagedData)} 参数异常,-101");
return null;
}
if (pageSize < 1 || pageSize > 10000)
throw new ArgumentException("分页大小应在1-10000之间");
{
_logger.LogError($"{nameof(GetAllPagedData)} 分页大小应在1-10000之间-102");
return null;
}
var luaScript = @"
local command = ARGV[1]
@ -504,7 +507,7 @@ return {#result_members, result_members, result_scores, hash_data}";
var hasNext = validItems.Count > pageSize;
var actualItems = hasNext ? validItems.Take(pageSize) : validItems;
// 修正分页锚点索引
//分页锚点索引
decimal? nextScore = null;
string nextMember = null;
if (hasNext && actualItems.Any())