Support zRem with multiple values
DATAREDIS-99
This commit is contained in:
@@ -1048,8 +1048,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
Boolean result = delegate.zRem(key, value);
|
||||
public Long zRem(byte[] key, byte[]... values) {
|
||||
Long result = delegate.zRem(key, values);
|
||||
if(isFutureConversion()) {
|
||||
addResultConverter(identityConverter);
|
||||
}
|
||||
@@ -2050,8 +2050,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Boolean zRem(String key, String value) {
|
||||
Boolean result = delegate.zRem(serialize(key), serialize(value));
|
||||
public Long zRem(String key, String... values) {
|
||||
Long result = delegate.zRem(serialize(key), serializeMulti(values));
|
||||
if(isFutureConversion()) {
|
||||
addResultConverter(identityConverter);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public interface RedisZSetCommands {
|
||||
|
||||
Long zAdd(byte[] key, Set<Tuple> tuples);
|
||||
|
||||
Boolean zRem(byte[] key, byte[] value);
|
||||
Long zRem(byte[] key, byte[]... values);
|
||||
|
||||
Double zIncrBy(byte[] key, double increment, byte[] value);
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ public interface StringRedisConnection extends RedisConnection {
|
||||
|
||||
Long zAdd(String key, Set<StringTuple> tuples);
|
||||
|
||||
Boolean zRem(String key, String value);
|
||||
Long zRem(String key, String... values);
|
||||
|
||||
Double zIncrBy(String key, double increment, String value);
|
||||
|
||||
|
||||
@@ -2209,17 +2209,21 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
public Long zRem(byte[] key, byte[]... values) {
|
||||
if((isPipelined() || isQueueing()) && values.length > 1) {
|
||||
throw new UnsupportedOperationException("zRem of multiple fields not supported " +
|
||||
"in pipeline or transaction");
|
||||
}
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new JedisResult(pipeline.zrem(key, value), JedisConverters.longToBoolean()));
|
||||
pipeline(new JedisResult(pipeline.zrem(key, values[0])));
|
||||
return null;
|
||||
}
|
||||
if (isQueueing()) {
|
||||
transaction(new JedisResult(transaction.zrem(key, value), JedisConverters.longToBoolean()));
|
||||
transaction(new JedisResult(transaction.zrem(key, values[0])));
|
||||
return null;
|
||||
}
|
||||
return JedisConverters.toBoolean(jedis.zrem(key, value));
|
||||
return jedis.zrem(key, values);
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -1057,9 +1057,12 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
public Long zRem(byte[] key, byte[]... values) {
|
||||
if(values.length > 1) {
|
||||
throw new UnsupportedOperationException("zRem of multiple fields not supported");
|
||||
}
|
||||
try {
|
||||
return jredis.zrem(key, value);
|
||||
return JredisUtils.toLong(jredis.zrem(key, values[0]));
|
||||
} catch (Exception ex) {
|
||||
throw convertJredisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -2304,17 +2304,17 @@ public class LettuceConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
public Long zRem(byte[] key, byte[]... values) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new LettuceResult(getAsyncConnection().zrem(key, value), LettuceConverters.longToBoolean()));
|
||||
pipeline(new LettuceResult(getAsyncConnection().zrem(key, values)));
|
||||
return null;
|
||||
}
|
||||
if (isQueueing()) {
|
||||
transaction(new LettuceTxResult(getConnection().zrem(key, value), LettuceConverters.longToBoolean()));
|
||||
transaction(new LettuceTxResult(getConnection().zrem(key, values)));
|
||||
return null;
|
||||
}
|
||||
return LettuceConverters.toBoolean(getConnection().zrem(key, value));
|
||||
return getConnection().zrem(key, values);
|
||||
} catch (Exception ex) {
|
||||
throw convertLettuceAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -1775,13 +1775,13 @@ public class SrpConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public Boolean zRem(byte[] key, byte[] value) {
|
||||
public Long zRem(byte[] key, byte[]... values) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new SrpResult(pipeline.zrem(key, new Object[] { value }), SrpConverters.longToBoolean()));
|
||||
pipeline(new SrpResult(pipeline.zrem(key, (Object[]) values)));
|
||||
return null;
|
||||
}
|
||||
return SrpConverters.toBoolean(client.zrem(key, new Object[] { value }).data());
|
||||
return client.zrem(key, (Object[]) values).data();
|
||||
} catch (Exception ex) {
|
||||
throw convertSrpAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
|
||||
|
||||
Long reverseRank(Object o);
|
||||
|
||||
Boolean remove(Object o);
|
||||
Long remove(Object... values);
|
||||
|
||||
Long count(double min, double max);
|
||||
|
||||
|
||||
@@ -121,8 +121,8 @@ class DefaultBoundZSetOperations<K, V> extends DefaultBoundKeyOperations<K> impl
|
||||
}
|
||||
|
||||
|
||||
public Boolean remove(Object o) {
|
||||
return ops.remove(getKey(), o);
|
||||
public Long remove(Object... values) {
|
||||
return ops.remove(getKey(), values);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -281,14 +281,14 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
|
||||
}
|
||||
|
||||
|
||||
public Boolean remove(K key, Object o) {
|
||||
public Long remove(K key, Object... values) {
|
||||
final byte[] rawKey = rawKey(key);
|
||||
final byte[] rawValue = rawValue(o);
|
||||
final byte[][] rawValues = rawValues(values);
|
||||
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
return execute(new RedisCallback<Long>() {
|
||||
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.zRem(rawKey, rawValue);
|
||||
public Long doInRedis(RedisConnection connection) {
|
||||
return connection.zRem(rawKey, rawValues);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public interface ZSetOperations<K, V> {
|
||||
|
||||
Double score(K key, Object o);
|
||||
|
||||
Boolean remove(K key, Object o);
|
||||
Long remove(K key, Object... values);
|
||||
|
||||
Long removeRange(K key, long start, long end);
|
||||
|
||||
|
||||
@@ -202,9 +202,9 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
|
||||
|
||||
|
||||
public boolean remove(Object o) {
|
||||
Boolean result = boundZSetOps.remove(o);
|
||||
Long result = boundZSetOps.remove(o);
|
||||
checkResult(result);
|
||||
return result;
|
||||
return result == 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user