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