feat(特色专区专项项目): 定制泛在专区开源项目展示需求

redis获取SortSet时分页参数可穿空

Signed-off-by: OTTO <731554297@qq.com>
This commit is contained in:
OTTO 2024-10-29 11:37:33 +08:00
parent 704c3c1fe4
commit d80b663bd5
1 changed files with 7 additions and 3 deletions

View File

@ -43,10 +43,14 @@ public class RedisService
redisTemplate.opsForZSet().remove(key, value);
}
public <T> Set<T> getSortSetBySize(final String key, final int offset, final int count) {
public <T> Set<T> getSortSetBySize(final String key, final Integer offset, final Integer count) {
RedisZSetCommands.Limit limit = new RedisZSetCommands.Limit();
limit.offset(offset);
limit.count(count);
if (offset != null && count != null) {
limit.offset(offset);
limit.count(count);
} else {
limit.isUnlimited();
}
return redisTemplate.opsForZSet().reverseRangeByLex(key, RedisZSetCommands.Range.unbounded(), limit);
}