0
0

绑定bug修复

This commit is contained in:
2025-10-11 16:07:14 +08:00
parent 740a638444
commit dab0440128
2 changed files with 21 additions and 2 deletions

View File

@ -394,6 +394,26 @@ public class RedisUtils {
return null;
}
}
/**
* 根据时间范围查询Sorted Set中的元素并降序排列
*
* @param key 键
* @param startTime 开始时间戳
* @param endTime 结束时间戳
* @return 指定时间范围内的元素集合(降序)
*/
public static Collection<String> zRangeByScoreDesc(String key, Long startTime, Long endTime) {
try {
RScoredSortedSet<String> sortedSet = CLIENT.getScoredSortedSet(key);
// 使用 valueRangeReversed 方法获取降序排列的结果
return sortedSet.valueRangeReversed(startTime, true, endTime, true);
} catch (Exception e) {
// 记录错误日志(如果项目中有日志工具的话)
// log.error("根据时间范围查询Sorted Set中的元素失败: key={}, startTime={}, endTime={}, error={}",
// key, startTime, endTime, e.getMessage(), e);
return null;
}
}
/**