zrange 查看排行榜 (升序)
zrevrange 查看排行榜 (降序)
zadd 添加一个数据
zrem 删除一个数据
zrank 获取排名(升序)
zrevrank 获取排名 (降序)
语文分数排序
ZSetOperations s=redisTemplate.opsForZSet();
s.removeRange("yuwen", 0, -1);
s.add("yuwen", "stu1", 1); //key-value-score
s.add("yuwen", "stu2", 3);
s.add("yuwen", "stu3", 2);
s.add("yuwen", "stu4", 100);
s.add("yuwen", "stu5", 80);
//升序
Set set=s.range("yuwen", 0, -1);
Iterator it= set.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
System.out.println("...");
double score=s.score("yuwen", "stu1");
System.out.println("score: "+score);
//倒序
Set mset=s.reverseRange("yuwen", 0, -1);
Iterator it2= mset.iterator();
while(it2.hasNext()) {
System.out.println(it2.next());
}