make set *store ops to return the resulting set size

DATAREDIS-86
This commit is contained in:
Costin Leau
2012-05-23 20:29:06 +03:00
parent 6028ba86ed
commit 646f1e3921
5 changed files with 36 additions and 33 deletions

View File

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

View File

@@ -39,15 +39,15 @@ public interface RedisSetCommands {
Set<byte[]> sInter(byte[]... keys);
void sInterStore(byte[] destKey, byte[]... keys);
Long sInterStore(byte[] destKey, byte[]... keys);
Set<byte[]> sUnion(byte[]... keys);
void sUnionStore(byte[] destKey, byte[]... keys);
Long sUnionStore(byte[] destKey, byte[]... keys);
Set<byte[]> sDiff(byte[]... keys);
void sDiffStore(byte[] destKey, byte[]... keys);
Long sDiffStore(byte[] destKey, byte[]... keys);
Set<byte[]> sMembers(byte[] key);

View File

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

View File

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

View File

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