diff --git a/src/main/java/org/springframework/data/redis/core/DefaultSetOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultSetOperations.java index 63ab5d37d..f34689880 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultSetOperations.java @@ -49,8 +49,6 @@ class DefaultSetOperations extends AbstractOperations implements Set return difference(key, Collections.singleton(otherKey)); } - @SuppressWarnings("unchecked") - public Set difference(final K key, final Collection otherKeys) { final byte[][] rawKeys = rawKeys(key, otherKeys); Set rawValues = execute(new RedisCallback>() { @@ -64,19 +62,18 @@ class DefaultSetOperations extends AbstractOperations implements Set } - 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 otherKeys, K destKey) { + public Long differenceAndStore(final K key, final Collection otherKeys, K destKey) { final byte[][] rawKeys = rawKeys(key, otherKeys); final byte[] rawDestKey = rawKey(destKey); - execute(new RedisCallback() { + return execute(new RedisCallback() { - 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 @@ class DefaultSetOperations extends AbstractOperations implements Set return intersect(key, Collections.singleton(otherKey)); } - @SuppressWarnings("unchecked") - public Set intersect(K key, Collection otherKeys) { final byte[][] rawKeys = rawKeys(key, otherKeys); Set rawValues = execute(new RedisCallback>() { @@ -101,17 +96,17 @@ class DefaultSetOperations extends AbstractOperations implements Set } - 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 otherKeys, K destKey) { + public Long intersectAndStore(K key, Collection otherKeys, K destKey) { final byte[][] rawKeys = rawKeys(key, otherKeys); final byte[] rawDestKey = rawKey(destKey); - execute(new RedisCallback() { + return execute(new RedisCallback() { - public Object doInRedis(RedisConnection connection) { + public Long doInRedis(RedisConnection connection) { connection.sInterStore(rawDestKey, rawKeys); return null; } @@ -130,8 +125,6 @@ class DefaultSetOperations extends AbstractOperations implements Set }, true); } - @SuppressWarnings("unchecked") - public Set members(K key) { final byte[] rawKey = rawKey(key); Set rawValues = execute(new RedisCallback>() { @@ -222,19 +215,18 @@ class DefaultSetOperations extends AbstractOperations implements Set } - 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 otherKeys, K destKey) { + public Long unionAndStore(K key, Collection otherKeys, K destKey) { final byte[][] rawKeys = rawKeys(key, otherKeys); final byte[] rawDestKey = rawKey(destKey); - execute(new RedisCallback() { + return execute(new RedisCallback() { - public Object doInRedis(RedisConnection connection) { - connection.sUnionStore(rawDestKey, rawKeys); - return null; + public Long doInRedis(RedisConnection connection) { + return connection.sUnionStore(rawDestKey, rawKeys); } }, true); } diff --git a/src/main/java/org/springframework/data/redis/core/SetOperations.java b/src/main/java/org/springframework/data/redis/core/SetOperations.java index b8a078bec..f54be4325 100644 --- a/src/main/java/org/springframework/data/redis/core/SetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/SetOperations.java @@ -30,25 +30,25 @@ public interface SetOperations { Set difference(K key, Collection otherKeys); - void differenceAndStore(K key, K otherKey, K destKey); + Long differenceAndStore(K key, K otherKey, K destKey); - void differenceAndStore(K key, Collection otherKeys, K destKey); + Long differenceAndStore(K key, Collection otherKeys, K destKey); Set intersect(K key, K otherKey); Set intersect(K key, Collection otherKeys); - void intersectAndStore(K key, K otherKey, K destKey); + Long intersectAndStore(K key, K otherKey, K destKey); - void intersectAndStore(K key, Collection otherKeys, K destKey); + Long intersectAndStore(K key, Collection otherKeys, K destKey); Set union(K key, K otherKey); Set union(K key, Collection otherKeys); - void unionAndStore(K key, K otherKey, K destKey); + Long unionAndStore(K key, K otherKey, K destKey); - void unionAndStore(K key, Collection otherKeys, K destKey); + Long unionAndStore(K key, Collection otherKeys, K destKey); Boolean add(K key, V value);