Make Template Set *storeOps() return the resulting set size

DATAREDIS-86
This commit is contained in:
Costin Leau
2012-05-23 20:35:17 +03:00
parent 042f3e8ca4
commit 8684be99fb
2 changed files with 16 additions and 18 deletions

View File

@@ -60,19 +60,18 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
}
public void intersectAndStore(K key, K otherKey, K destKey) {
intersectAndStore(key, Collections.singleton(otherKey), destKey);
public Long intersectAndStore(K key, K otherKey, K destKey) {
return intersectAndStore(key, Collections.singleton(otherKey), destKey);
}
public void intersectAndStore(K key, Collection<K> otherKeys, K destKey) {
public Long intersectAndStore(K key, Collection<K> otherKeys, K destKey) {
final byte[][] rawKeys = rawKeys(key, otherKeys);
final byte[] rawDestKey = rawKey(destKey);
execute(new RedisCallback<Object>() {
return execute(new RedisCallback<Long>() {
public Object doInRedis(RedisConnection connection) {
connection.zInterStore(rawDestKey, rawKeys);
return null;
public Long doInRedis(RedisConnection connection) {
return connection.zInterStore(rawDestKey, rawKeys);
}
}, true);
}
@@ -294,19 +293,18 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
}
public void unionAndStore(K key, K otherKey, K destKey) {
unionAndStore(key, Collections.singleton(otherKey), destKey);
public Long unionAndStore(K key, K otherKey, K destKey) {
return unionAndStore(key, Collections.singleton(otherKey), destKey);
}
public void unionAndStore(K key, Collection<K> otherKeys, K destKey) {
public Long unionAndStore(K key, Collection<K> otherKeys, K destKey) {
final byte[][] rawKeys = rawKeys(key, otherKeys);
final byte[] rawDestKey = rawKey(destKey);
execute(new RedisCallback<Object>() {
return execute(new RedisCallback<Long>() {
public Object doInRedis(RedisConnection connection) {
connection.zUnionStore(rawDestKey, rawKeys);
return null;
public Long doInRedis(RedisConnection connection) {
return connection.zUnionStore(rawDestKey, rawKeys);
}
}, true);
}

View File

@@ -35,13 +35,13 @@ public interface ZSetOperations<K, V> {
Double getScore();
}
void intersectAndStore(K key, K otherKey, K destKey);
Long intersectAndStore(K key, K otherKey, K destKey);
void intersectAndStore(K key, Collection<K> otherKeys, K destKey);
Long intersectAndStore(K key, Collection<K> otherKeys, K destKey);
void unionAndStore(K key, K otherKey, K destKey);
Long unionAndStore(K key, K otherKey, K destKey);
void unionAndStore(K key, Collection<K> otherKeys, K destKey);
Long unionAndStore(K key, Collection<K> otherKeys, K destKey);
Set<V> range(K key, long start, long end);