+ add support for zset count
This commit is contained in:
@@ -53,6 +53,8 @@ public interface BoundZSetOperations<K, V> extends KeyBound<K> {
|
||||
|
||||
Boolean remove(Object o);
|
||||
|
||||
Long count(double min, double max);
|
||||
|
||||
Long size();
|
||||
|
||||
Double score(Object o);
|
||||
|
||||
@@ -104,6 +104,11 @@ class DefaultBoundZSetOperations<K, V> extends DefaultKeyBound<K> implements Bou
|
||||
return ops.reverseRange(getKey(), start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count(double min, double max) {
|
||||
return ops.count(getKey(), min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size() {
|
||||
return ops.size(getKey());
|
||||
|
||||
@@ -1488,6 +1488,18 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count(K key, final double min, final double max) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
return execute(new RedisCallback<Long>() {
|
||||
@Override
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.zCount(rawKey, min, max);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long size(K key) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
|
||||
@@ -52,6 +52,8 @@ public interface ZSetOperations<K, V> {
|
||||
|
||||
void removeRangeByScore(K key, double min, double max);
|
||||
|
||||
Long count(K key, double min, double max);
|
||||
|
||||
Long size(K key);
|
||||
|
||||
RedisOperations<K, V> getOperations();
|
||||
|
||||
Reference in New Issue
Block a user