使用redis的zset进行原子增及统计
maven
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
</dependency>
incr
redisTemplate.boundZSetOps("myzset").incrementScore(key,1L);
sort
int start = (page - 1) * PAGE_SIZE;
int end = start + PAGE_SIZE - 1;
Set<ZSetOperations.TypedTuple<String>> reportCodes = redisTemplate
.boundZSetOps("myzset")
.reverseRangeWithScores(start,end);
doc
[ZRANGE key start stop [WITHSCORES]](https://redis.io/commands/zra…