RedisTemplate-opsForZSet集合スコア-api


1、add(K key, V value, double score)
                 。
redisTemplate.opsForZSet().add("zSetValue","A",1);  
redisTemplate.opsForZSet().add("zSetValue","B",3);  
redisTemplate.opsForZSet().add("zSetValue","C",2);  
redisTemplate.opsForZSet().add("zSetValue","D",5);  


2、range(K key, long start, long end)
           。
Set zSetValue = redisTemplate.opsForZSet().range("zSetValue",0,-1);  
System.out.println("       :" + zSetValue);  
 

3、rangeByLex(K key, RedisZSetCommands.Range range)
       score     。                    ,               。
RedisZSetCommands.Range range = new RedisZSetCommands.Range();  
//range.gt("A");  
range.lt("D");  
zSetValue = redisTemplate.opsForZSet().rangeByLex("zSetValue", range);  
System.out.println("     score       :" + zSetValue);  
           

4、rangeByLex(K key, RedisZSetCommands.Range range, RedisZSetCommands.Limit limit)
       score              。
RedisZSetCommands.Limit limit = new RedisZSetCommands.Limit();  
limit.count(2);  
//     0  
limit.offset(1);  
zSetValue = redisTemplate.opsForZSet().rangeByLex("zSetValue", range,limit);  
System.out.println("   score       :" + zSetValue);  
 

5、add(K key, Set> tuples)
  TypedTuple      。
ZSetOperations.TypedTuple typedTuple1 = new DefaultTypedTuple("E",6.0);  
ZSetOperations.TypedTuple typedTuple2 = new DefaultTypedTuple("F",7.0);  
ZSetOperations.TypedTuple typedTuple3 = new DefaultTypedTuple("G",5.0);  
Set> typedTupleSet = new HashSet>();  
typedTupleSet.add(typedTuple1);  
typedTupleSet.add(typedTuple2);  
typedTupleSet.add(typedTuple3);  
redisTemplate.opsForZSet().add("typedTupleSet",typedTupleSet);  
zSetValue = redisTemplate.opsForZSet().range("typedTupleSet",0,-1);  
System.out.println("    :" + zSetValue);  
 

6、rangeByScore(K key, double min, double max)
     score     。
zSetValue = redisTemplate.opsForZSet().rangeByScore("zSetValue",1,2);  
System.out.println("   :" + zSetValue);  
 

7、rangeByScore(K key, double min, double max,long offset, long count)
     score                    。
zSetValue = redisTemplate.opsForZSet().rangeByScore("zSetValue",1,5,1,3);  
System.out.println("     score     :" + zSetValue);  
 

8、rangeWithScores(K key, long start, long end)
  RedisZSetCommands.Tuples    。
Set> typedTupleSet = redisTemplate.opsForZSet().rangeWithScores("typedTupleSet",1,3);  
Iterator> iterator = typedTupleSet.iterator();  
while (iterator.hasNext()){  
    ZSetOperations.TypedTuple typedTuple = iterator.next();  
    Object value = typedTuple.getValue();  
    double score = typedTuple.getScore();  
    System.out.println("  RedisZSetCommands.Tuples    :" + value + "---->" + score );  
}  
 

9、rangeByScoreWithScores(K key, double min, double max)
  RedisZSetCommands.Tuples        。
Set> typedTupleSet = redisTemplate.opsForZSet().rangeByScoreWithScores("typedTupleSet",5,8);  
iterator = typedTupleSet.iterator();  
while (iterator.hasNext()){  
    ZSetOperations.TypedTuple typedTuple = iterator.next();  
    Object value = typedTuple.getValue();  
    double score = typedTuple.getScore();  
    System.out.println("       :" + value + "---->" + score );  
}  
 

10、rangeByScoreWithScores(K key, double min, double max, long offset, long count)
  RedisZSetCommands.Tuples                       。
Set> typedTupleSet = redisTemplate.opsForZSet().rangeByScoreWithScores("typedTupleSet",5,8,1,1);  
iterator = typedTupleSet.iterator();  
while (iterator.hasNext()){  
    ZSetOperations.TypedTuple typedTuple = iterator.next();  
    Object value = typedTuple.getValue();  
    double score = typedTuple.getScore();  
    System.out.println("    :" + value + "---->" + score );  
}  
 

11、count(K key, double min, double max)
        。
long count = redisTemplate.opsForZSet().count("zSetValue",1,5);  
System.out.println("  :" + count);  
 

12、rank(K key, Object o)
          ,       0。
long index = redisTemplate.opsForZSet().rank("zSetValue","B");  
System.out.println("          :" + index);  
 

13、scan(K key, ScanOptions options)
       ,ScanOptions.NONE        ;ScanOptions.scanOptions().match("C").build()      map1    ,      。
//Cursor cursor = redisTemplate.opsForSet().scan("setValue", ScanOptions.NONE);  
Cursor> cursor = redisTemplate.opsForZSet().scan("zSetValue", ScanOptions.NONE);  
while (cursor.hasNext()){  
    ZSetOperations.TypedTuple typedTuple = cursor.next();  
    System.out.println("  :" + typedTuple.getValue() + "--->" + typedTuple.getScore());  
}  
 

14、score(K key, Object o)
       。
double score = redisTemplate.opsForZSet().score("zSetValue","B");  
System.out.println("     :" + score);  
 

15、zCard(K key)
          。
long zCard = redisTemplate.opsForZSet().zCard("zSetValue");  
System.out.println("     :" + zCard);  
 

16、incrementScore(K key, V value, double delta)
           。
double incrementScore = redisTemplate.opsForZSet().incrementScore("zSetValue","C",5);  
System.out.print("  incrementScore(K key, V value, double delta)             :" + incrementScore);  
score = redisTemplate.opsForZSet().score("zSetValue","C");  
System.out.print(",          :" + score);  
zSetValue = redisTemplate.opsForZSet().range("zSetValue",0,-1);  
System.out.println(",        :" + zSetValue);  
 

17、reverseRange(K key, long start, long end)
            。
zSetValue = redisTemplate.opsForZSet().reverseRange("zSetValue",0,-1);  
System.out.println("      :" + zSetValue);  
 

18、reverseRangeByScore(K key, double min, double max)
            。
zSetValue = redisTemplate.opsForZSet().reverseRangeByScore("zSetValue",1,5);  
System.out.println("  :" + zSetValue);  
 

19、reverseRangeByScore(K key, double min, double max, long offset, long count)
                    。
zSetValue = redisTemplate.opsForZSet().reverseRangeByScore("zSetValue",1,5,1,2);  
System.out.println("    :" + zSetValue);  
 

20、reverseRangeByScoreWithScores(K key, double min, double max)
      RedisZSetCommands.Tuples      。
Set> typedTupleSet = redisTemplate.opsForZSet().reverseRangeByScoreWithScores("zSetValue",1,5);  
iterator = typedTupleSet.iterator();  
while (iterator.hasNext()){  
    ZSetOperations.TypedTuple typedTuple = iterator.next();  
    Object value = typedTuple.getValue();  
    double score1 = typedTuple.getScore();  
    System.out.println("   :" + value + "---->" + score1 );  
}  


21、reverseRangeByScoreWithScores(K key, double min, double max, long offset, long count)
      RedisZSetCommands.Tuples                。
Set> typedTupleSet = redisTemplate.opsForZSet().reverseRangeByScoreWithScores("zSetValue",1,5,1,2);  
iterator = typedTupleSet.iterator();  
while (iterator.hasNext()){  
    ZSetOperations.TypedTuple typedTuple = iterator.next();  
    Object value = typedTuple.getValue();  
    double score1 = typedTuple.getScore();  
    System.out.println("   :" + value + "---->" + score1 );  
}  


22、reverseRangeWithScores(K key, long start, long end)
         。
Set> typedTupleSet = redisTemplate.opsForZSet().reverseRangeWithScores("zSetValue",1,5);  
iterator = typedTupleSet.iterator();  
while (iterator.hasNext()){  
    ZSetOperations.TypedTuple typedTuple = iterator.next();  
    Object value = typedTuple.getValue();  
    double score1 = typedTuple.getScore();  
    System.out.println("   :" + value + "----->" + score1);  
}  


23、reverseRank(K key, Object o)
          。
long reverseRank = redisTemplate.opsForZSet().reverseRank("zSetValue","B");  
System.out.println("   :" + reverseRank);  


24、intersectAndStore(K key, K otherKey, K destKey)
  2          3     。
redisTemplate.opsForZSet().intersectAndStore("zSetValue","typedTupleSet","intersectSet");  
zSetValue = redisTemplate.opsForZSet().range("intersectSet",0,-1);  
System.out.println("  :" + zSetValue); 

 
25、intersectAndStore(K key, Collection otherKeys, K destKey)
             3     。
List list = new ArrayList();  
list.add("typedTupleSet");  
redisTemplate.opsForZSet().intersectAndStore("zSetValue",list,"intersectListSet");  
zSetValue = redisTemplate.opsForZSet().range("intersectListSet",0,-1);  
System.out.println("  :" + zSetValue);

  
26、unionAndStore(K key, K otherKey, K destKey)
  2          3     。
redisTemplate.opsForZSet().unionAndStore("zSetValue","typedTupleSet","unionSet");  
zSetValue = redisTemplate.opsForZSet().range("unionSet",0,-1);  
System.out.println("  :" + zSetValue);  


27、unionAndStore(K key, Collection otherKeys, K destKey)
             3     。
redisTemplate.opsForZSet().unionAndStore("zSetValue",list,"unionListSet");  
zSetValue = redisTemplate.opsForZSet().range("unionListSet",0,-1);  
System.out.println("  :" + zSetValue); 

 
28、remove(K key, Object... values)
           。
long removeCount = redisTemplate.opsForZSet().remove("unionListSet","A","B");  
zSetValue = redisTemplate.opsForZSet().range("unionListSet",0,-1);  
System.out.print("       :" + removeCount);  
System.out.println(",        :" + zSetValue);  


29、removeRangeByScore(K key, double min, double max)
          。
removeCount = redisTemplate.opsForZSet().removeRangeByScore("unionListSet",3,5);  
zSetValue = redisTemplate.opsForZSet().range("unionListSet",0,-1);  
System.out.print("       :" + removeCount);  
System.out.println(",        :" + zSetValue);  


30、removeRange(K key, long start, long end)
           。
removeCount = redisTemplate.opsForZSet().removeRange("unionListSet",3,5);  
zSetValue = redisTemplate.opsForZSet().range("unionListSet",0,-1);  
System.out.print("       :" + removeCount);  
System.out.println(",        :" + zSetValue);