+ add support for zset count

This commit is contained in:
Costin Leau
2011-01-10 17:44:37 +02:00
parent 998c187525
commit 1b0a16cf1c
4 changed files with 21 additions and 0 deletions

View File

@@ -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);

View File

@@ -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());

View File

@@ -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);

View File

@@ -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();