Redis的StringRedisTemplate在SpringBoot中的使用完全整理之opsForZSet

opsForZSet

 

目录

opsForZSet

add(String k,String v,double v1)

add(K key, Set> tuples)

count(String k,double v,double v1)

incrementScore(String k,String v,double v1)

intersectAndStore(String k,String k1,String k2)、intersectAndStore(String k,Collection collection,String k1)、intersectAndStore(String key,Collection otherKeys,String destKey,Aggregate aggretate)、intersectAndStore(String k,Collection collection,String destKey,Aggregate aggretate,Weights weights)

range(String k,long l,long l1)

rangByLex(String k,Range range)、rangByLex(String k,Range range,Limit limit)

rangeByScore(String k,double v,double v1)、rangeByScore(String k,double v,double v1,long l,long l1)

rangeByScoreWithScores(String k,double v,double v1)、rangeByScoreWithScores(String k,double v,double v1,long l,long l1)

rank(String k,Object o)

remove(String k,Object... objects)

removeByRange(String k,long l,long 1l)

removeByScore(String k,double v,double v1)

unionAndStore(String k,String k1,String k2)、unionAndStore(String k,Collection collection,String k1)、unionAndStore(String key,Collection otherKeys,String destKey,Aggregate aggretate)、unionAndStore(String k,Collection collection,String destKey,Aggregate aggretate,Weights weights)

reverseRange(String k,long l,long l1)、reverseRangeByScore(String k,double v,double v1)、reverseRangeByScore(String k,double v,double v1,long l,long l1)、reverseRangeByScoreWithScores(String k,double v,double v1)、reverseRangeByScoreWithScores(String k,double v,double v1,long l,long l1)、reverseRangeWithScores(String k,long l,long l1)

size(String k)

score(String k,Object o)

zCard(String k)


add(String k,String v,double v1)

向有序集合k添加元素v并设置它的分数为v1

add(K key, Set<ZSetOperations.TypedTuple<V>> tuples)

 通过TypedTuple方式新增数据。

eg:

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)

count(String k,double v,double v1)

获取分数在v-v1之间的元素的个数

incrementScore(String k,String v,double v1)

增加集合k元素v的份数值。

intersectAndStore(String k,String k1,String k2)、intersectAndStore(String k,Collection collection,String k1)、intersectAndStore(String key,Collection otherKeys,String destKey,Aggregate aggretate)、intersectAndStore(String k,Collection collection,String destKey,Aggregate aggretate,Weights weights)

获取集合的交集并存储在新的集合中。

range(String k,long l,long l1)

获取集合l-l1之间的元素(不包括l),返回一个Set

rangByLex(String k,Range range)、rangByLex(String k,Range range,Limit limit)

暂未研究

rangeByScore(String k,double v,double v1)、rangeByScore(String k,double v,double v1,long l,long l1)

根据分数在集合中查找或者集合区间查找元素,返回Set

rangeByScoreWithScores(String k,double v,double v1)、rangeByScoreWithScores(String k,double v,double v1,long l,long l1)

根据分数在集合中查找或者集合区间查找元素,返回Set>

rank(String k,Object o)

获取集合中o元素的位置,返回其下标。

remove(String k,Object... objects)

移除集合中的多个元素

removeByRange(String k,long l,long 1l)

移除集合下标范围内的元素,不包括l。

removeByScore(String k,double v,double v1)

移除集合分数范围内的元素

unionAndStore(String k,String k1,String k2)、unionAndStore(String k,Collection collection,String k1)、unionAndStore(String key,Collection otherKeys,String destKey,Aggregate aggretate)、unionAndStore(String k,Collection collection,String destKey,Aggregate aggretate,Weights weights)

获取集合的并集放到新的集合中。

 

reverseRange(String k,long l,long l1)、reverseRangeByScore(String k,double v,double v1)、reverseRangeByScore(String k,double v,double v1,long l,long l1)、reverseRangeByScoreWithScores(String k,double v,double v1)、reverseRangeByScoreWithScores(String k,double v,double v1,long l,long l1)、reverseRangeWithScores(String k,long l,long l1)

这些方法都是倒序获取集合中的元素。

size(String k)

获取集合大小。

score(String k,Object o)

获取集合中元素的分数。

zCard(String k)

获取集合中元素的个数。

你可能感兴趣的:(Redis)