Permalink
Browse files

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

DATAREDIS-86
  • Loading branch information...
1 parent 646f1e3 commit 042f3e8ca40dcf374bbe0e16e9ebc5756f7701ca Costin Leau committed May 23, 2012
@@ -49,8 +49,6 @@ public Boolean doInRedis(RedisConnection connection) {
return difference(key, Collections.singleton(otherKey));
}
- @SuppressWarnings("unchecked")
-
public Set<V> difference(final K key, final Collection<K> otherKeys) {
final byte[][] rawKeys = rawKeys(key, otherKeys);
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
@@ -64,19 +62,18 @@ public Boolean doInRedis(RedisConnection connection) {
}
- public void differenceAndStore(K key, K otherKey, K destKey) {
- differenceAndStore(key, Collections.singleton(otherKey), destKey);
+ public Long differenceAndStore(K key, K otherKey, K destKey) {
+ return differenceAndStore(key, Collections.singleton(otherKey), destKey);
}
- public void differenceAndStore(final K key, final Collection<K> otherKeys, K destKey) {
+ public Long differenceAndStore(final K key, final 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.sDiffStore(rawDestKey, rawKeys);
- return null;
+ public Long doInRedis(RedisConnection connection) {
+ return connection.sDiffStore(rawDestKey, rawKeys);
}
}, true);
}
@@ -86,8 +83,6 @@ public Object doInRedis(RedisConnection connection) {
return intersect(key, Collections.singleton(otherKey));
}
- @SuppressWarnings("unchecked")
-
public Set<V> intersect(K key, Collection<K> otherKeys) {
final byte[][] rawKeys = rawKeys(key, otherKeys);
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
@@ -101,17 +96,17 @@ public Object doInRedis(RedisConnection connection) {
}
- 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) {
+ public Long doInRedis(RedisConnection connection) {
connection.sInterStore(rawDestKey, rawKeys);
return null;
}
@@ -130,8 +125,6 @@ public Boolean doInRedis(RedisConnection connection) {
}, true);
}
- @SuppressWarnings("unchecked")
-
public Set<V> members(K key) {
final byte[] rawKey = rawKey(key);
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
@@ -222,19 +215,18 @@ public Long doInRedis(RedisConnection connection) {
}
- 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.sUnionStore(rawDestKey, rawKeys);
- return null;
+ public Long doInRedis(RedisConnection connection) {
+ return connection.sUnionStore(rawDestKey, rawKeys);
}
}, true);
}
@@ -30,25 +30,25 @@
Set<V> difference(K key, Collection<K> otherKeys);
- void differenceAndStore(K key, K otherKey, K destKey);
+ Long differenceAndStore(K key, K otherKey, K destKey);
- void differenceAndStore(K key, Collection<K> otherKeys, K destKey);
+ Long differenceAndStore(K key, Collection<K> otherKeys, K destKey);
Set<V> intersect(K key, K otherKey);
Set<V> intersect(K key, Collection<K> otherKeys);
- 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);
Set<V> union(K key, K otherKey);
Set<V> union(K key, Collection<K> otherKeys);
- 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);
Boolean add(K key, V value);

0 comments on commit 042f3e8

Please sign in to comment.