diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java index 191b87cfc..97012ddaa 100644 --- a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java @@ -372,8 +372,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection { return delegate.sDiff(keys); } - public void sDiffStore(byte[] destKey, byte[]... keys) { - delegate.sDiffStore(destKey, keys); + public Long sDiffStore(byte[] destKey, byte[]... keys) { + return delegate.sDiffStore(destKey, keys); } public void select(int dbIndex) { @@ -412,8 +412,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection { return delegate.sInter(keys); } - public void sInterStore(byte[] destKey, byte[]... keys) { - delegate.sInterStore(destKey, keys); + public Long sInterStore(byte[] destKey, byte[]... keys) { + return delegate.sInterStore(destKey, keys); } public Boolean sIsMember(byte[] key, byte[] value) { @@ -460,8 +460,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection { return delegate.sUnion(keys); } - public void sUnionStore(byte[] destKey, byte[]... keys) { - delegate.sUnionStore(destKey, keys); + public Long sUnionStore(byte[] destKey, byte[]... keys) { + return delegate.sUnionStore(destKey, keys); } public Long ttl(byte[] key) { diff --git a/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java index f3ec271ef..3c07ae99b 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java @@ -39,15 +39,15 @@ public interface RedisSetCommands { Set sInter(byte[]... keys); - void sInterStore(byte[] destKey, byte[]... keys); + Long sInterStore(byte[] destKey, byte[]... keys); Set sUnion(byte[]... keys); - void sUnionStore(byte[] destKey, byte[]... keys); + Long sUnionStore(byte[] destKey, byte[]... keys); Set sDiff(byte[]... keys); - void sDiffStore(byte[] destKey, byte[]... keys); + Long sDiffStore(byte[] destKey, byte[]... keys); Set sMembers(byte[] key); diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java index 7899ab558..bd764940b 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java @@ -1423,17 +1423,17 @@ public class JedisConnection implements RedisConnection { } - public void sDiffStore(byte[] destKey, byte[]... keys) { + public Long sDiffStore(byte[] destKey, byte[]... keys) { try { if (isQueueing()) { transaction.sdiffstore(destKey, keys); - return; + return null; } if (isPipelined()) { pipeline.sdiffstore(destKey, keys); - return; + return null; } - jedis.sdiffstore(destKey, keys); + return jedis.sdiffstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); } @@ -1457,17 +1457,17 @@ public class JedisConnection implements RedisConnection { } - public void sInterStore(byte[] destKey, byte[]... keys) { + public Long sInterStore(byte[] destKey, byte[]... keys) { try { if (isQueueing()) { transaction.sinterstore(destKey, keys); - return; + return null; } if (isPipelined()) { pipeline.sinterstore(destKey, keys); - return; + return null; } - jedis.sinterstore(destKey, keys); + return jedis.sinterstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); } @@ -1593,17 +1593,17 @@ public class JedisConnection implements RedisConnection { } - public void sUnionStore(byte[] destKey, byte[]... keys) { + public Long sUnionStore(byte[] destKey, byte[]... keys) { try { if (isQueueing()) { transaction.sunionstore(destKey, keys); - return; + return null; } if (isPipelined()) { pipeline.sunionstore(destKey, keys); - return; + return null; } - jedis.sunionstore(destKey, keys); + return jedis.sunionstore(destKey, keys); } catch (Exception ex) { throw convertJedisAccessException(ex); } diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java b/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java index e7d4a3a92..2ea1d5556 100644 --- a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java @@ -710,12 +710,13 @@ public class JredisConnection implements RedisConnection { } - public void sDiffStore(byte[] destKey, byte[]... keys) { + public Long sDiffStore(byte[] destKey, byte[]... keys) { String destSet = JredisUtils.decode(destKey); String[] sets = JredisUtils.decodeMultiple(keys); try { jredis.sdiffstore(destSet, sets); + return Long.valueOf(-1); } catch (Exception ex) { throw convertJredisAccessException(ex); } @@ -735,12 +736,13 @@ public class JredisConnection implements RedisConnection { } - public void sInterStore(byte[] destKey, byte[]... keys) { + public Long sInterStore(byte[] destKey, byte[]... keys) { String destSet = JredisUtils.decode(destKey); String[] sets = JredisUtils.decodeMultiple(keys); try { jredis.sinterstore(destSet, sets); + return Long.valueOf(-1); } catch (Exception ex) { throw convertJredisAccessException(ex); } @@ -813,12 +815,13 @@ public class JredisConnection implements RedisConnection { } - public void sUnionStore(byte[] destKey, byte[]... keys) { + public Long sUnionStore(byte[] destKey, byte[]... keys) { String destSet = JredisUtils.decode(destKey); String[] sets = JredisUtils.decodeMultiple(keys); try { jredis.sunionstore(destSet, sets); + return Long.valueOf(-1); } catch (Exception ex) { throw convertJredisAccessException(ex); } diff --git a/src/main/java/org/springframework/data/redis/connection/rjc/RjcConnection.java b/src/main/java/org/springframework/data/redis/connection/rjc/RjcConnection.java index 19c7a6fc6..67a3b5801 100644 --- a/src/main/java/org/springframework/data/redis/connection/rjc/RjcConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/rjc/RjcConnection.java @@ -1254,7 +1254,7 @@ public class RjcConnection implements RedisConnection { } - public void sDiffStore(byte[] destKey, byte[]... keys) { + public Long sDiffStore(byte[] destKey, byte[]... keys) { String stringKey = RjcUtils.decode(destKey); String[] stringKeys = RjcUtils.decodeMultiple(keys); @@ -1262,9 +1262,9 @@ public class RjcConnection implements RedisConnection { if (isPipelined()) { pipeline.sdiffstore(stringKey, stringKeys); - return; + return null; } - session.sdiffstore(stringKey, stringKeys); + return session.sdiffstore(stringKey, stringKeys); } catch (Exception ex) { throw convertRjcAccessException(ex); } @@ -1286,16 +1286,16 @@ public class RjcConnection implements RedisConnection { } - public void sInterStore(byte[] destKey, byte[]... keys) { + public Long sInterStore(byte[] destKey, byte[]... keys) { String stringKey = RjcUtils.decode(destKey); String[] stringKeys = RjcUtils.decodeMultiple(keys); try { if (isPipelined()) { pipeline.sinterstore(stringKey, stringKeys); - return; + return null; } - session.sinterstore(stringKey, stringKeys); + return session.sinterstore(stringKey, stringKeys); } catch (Exception ex) { throw convertRjcAccessException(ex); } @@ -1415,7 +1415,7 @@ public class RjcConnection implements RedisConnection { } - public void sUnionStore(byte[] destKey, byte[]... keys) { + public Long sUnionStore(byte[] destKey, byte[]... keys) { String stringKey = RjcUtils.decode(destKey); String[] stringKeys = RjcUtils.decodeMultiple(keys); @@ -1423,9 +1423,9 @@ public class RjcConnection implements RedisConnection { if (isPipelined()) { pipeline.sunionstore(stringKey, stringKeys); - return; + return null; } - session.sunionstore(stringKey, stringKeys); + return session.sunionstore(stringKey, stringKeys); } catch (Exception ex) { throw convertRjcAccessException(ex); } 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/DefaultZSetOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultZSetOperations.java index 5cf540faa..79382b4f2 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultZSetOperations.java @@ -60,19 +60,18 @@ class DefaultZSetOperations extends AbstractOperations 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 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) { - connection.zInterStore(rawDestKey, rawKeys); - return null; + public Long doInRedis(RedisConnection connection) { + return connection.zInterStore(rawDestKey, rawKeys); } }, true); } @@ -233,25 +232,23 @@ class DefaultZSetOperations extends AbstractOperations implements ZS } - public void removeRange(K key, final long start, final long end) { + public Long removeRange(K key, final long start, final long end) { final byte[] rawKey = rawKey(key); - execute(new RedisCallback() { + return execute(new RedisCallback() { - public Object doInRedis(RedisConnection connection) { - connection.zRemRange(rawKey, start, end); - return null; + public Long doInRedis(RedisConnection connection) { + return connection.zRemRange(rawKey, start, end); } }, true); } - public void removeRangeByScore(K key, final double min, final double max) { + public Long removeRangeByScore(K key, final double min, final double max) { final byte[] rawKey = rawKey(key); - execute(new RedisCallback() { + return execute(new RedisCallback() { - public Object doInRedis(RedisConnection connection) { - connection.zRemRangeByScore(rawKey, min, max); - return null; + public Long doInRedis(RedisConnection connection) { + return connection.zRemRangeByScore(rawKey, min, max); } }, true); } @@ -294,19 +291,18 @@ class DefaultZSetOperations extends AbstractOperations 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 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.zUnionStore(rawDestKey, rawKeys); - return null; + public Long doInRedis(RedisConnection connection) { + return connection.zUnionStore(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); diff --git a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java index 54a363d1e..4014e4c9e 100644 --- a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java @@ -35,13 +35,13 @@ public interface ZSetOperations { Double getScore(); } - 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); - 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); Set range(K key, long start, long end); @@ -71,9 +71,9 @@ public interface ZSetOperations { Boolean remove(K key, Object o); - void removeRange(K key, long start, long end); + Long removeRange(K key, long start, long end); - void removeRangeByScore(K key, double min, double max); + Long removeRangeByScore(K key, double min, double max); Long count(K key, double min, double max);