Change mSetNX/multiSetIfAbsent return type to Boolean
DATAREDIS-177
This commit is contained in:
@@ -304,8 +304,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
delegate.mSet(tuple);
|
||||
}
|
||||
|
||||
public void mSetNX(Map<byte[], byte[]> tuple) {
|
||||
delegate.mSetNX(tuple);
|
||||
public Boolean mSetNX(Map<byte[], byte[]> tuple) {
|
||||
return delegate.mSetNX(tuple);
|
||||
}
|
||||
|
||||
public void multi() {
|
||||
@@ -919,8 +919,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public void mSetNXString(Map<String, String> tuple) {
|
||||
delegate.mSetNX(serialize(tuple));
|
||||
public Boolean mSetNXString(Map<String, String> tuple) {
|
||||
return delegate.mSetNX(serialize(tuple));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface RedisStringCommands {
|
||||
|
||||
void mSet(Map<byte[], byte[]> tuple);
|
||||
|
||||
void mSetNX(Map<byte[], byte[]> tuple);
|
||||
Boolean mSetNX(Map<byte[], byte[]> tuple);
|
||||
|
||||
Long incr(byte[] key);
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public interface StringRedisConnection extends RedisConnection {
|
||||
|
||||
void mSetString(Map<String, String> tuple);
|
||||
|
||||
void mSetNXString(Map<String, String> tuple);
|
||||
Boolean mSetNXString(Map<String, String> tuple);
|
||||
|
||||
Long incr(String key);
|
||||
|
||||
|
||||
@@ -985,17 +985,17 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public void mSetNX(Map<byte[], byte[]> tuples) {
|
||||
public Boolean mSetNX(Map<byte[], byte[]> tuples) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
transaction.msetnx(JedisUtils.convert(tuples));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (isPipelined()) {
|
||||
pipeline.msetnx(JedisUtils.convert(tuples));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
jedis.msetnx(JedisUtils.convert(tuples));
|
||||
return JedisUtils.convertCodeReply(jedis.msetnx(JedisUtils.convert(tuples)));
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -516,9 +516,9 @@ public class JredisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public void mSetNX(Map<byte[], byte[]> tuple) {
|
||||
public Boolean mSetNX(Map<byte[], byte[]> tuple) {
|
||||
try {
|
||||
jredis.msetnx(tuple);
|
||||
return jredis.msetnx(tuple);
|
||||
} catch (Exception ex) {
|
||||
throw convertJredisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -873,13 +873,13 @@ public class LettuceConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public void mSetNX(Map<byte[], byte[]> tuples) {
|
||||
public Boolean mSetNX(Map<byte[], byte[]> tuples) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(getAsyncConnection().msetnx(tuples));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
getConnection().msetnx(tuples);
|
||||
return getConnection().msetnx(tuples);
|
||||
} catch (Exception ex) {
|
||||
throw convertLettuceAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -802,13 +802,13 @@ public class SrpConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
|
||||
public void mSetNX(Map<byte[], byte[]> tuples) {
|
||||
public Boolean mSetNX(Map<byte[], byte[]> tuples) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(pipeline.msetnx((Object[]) SrpUtils.convert(tuples)));
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
client.msetnx((Object[]) SrpUtils.convert(tuples));
|
||||
return SrpUtils.asBoolean(client.msetnx((Object[]) SrpUtils.convert(tuples)));
|
||||
} catch (Exception ex) {
|
||||
throw convertSrpAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -149,9 +149,9 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
}
|
||||
|
||||
|
||||
public void multiSetIfAbsent(Map<? extends K, ? extends V> m) {
|
||||
public Boolean multiSetIfAbsent(Map<? extends K, ? extends V> m) {
|
||||
if (m.isEmpty()) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
final Map<byte[], byte[]> rawKeys = new LinkedHashMap<byte[], byte[]>(m.size());
|
||||
@@ -160,11 +160,10 @@ class DefaultValueOperations<K, V> extends AbstractOperations<K, V> implements V
|
||||
rawKeys.put(rawKey(entry.getKey()), rawValue(entry.getValue()));
|
||||
}
|
||||
|
||||
execute(new RedisCallback<Object>() {
|
||||
return execute(new RedisCallback<Boolean>() {
|
||||
|
||||
public Object doInRedis(RedisConnection connection) {
|
||||
connection.mSetNX(rawKeys);
|
||||
return null;
|
||||
public Boolean doInRedis(RedisConnection connection) {
|
||||
return connection.mSetNX(rawKeys);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public interface ValueOperations<K, V> {
|
||||
|
||||
void multiSet(Map<? extends K, ? extends V> m);
|
||||
|
||||
void multiSetIfAbsent(Map<? extends K, ? extends V> m);
|
||||
Boolean multiSetIfAbsent(Map<? extends K, ? extends V> m);
|
||||
|
||||
V get(Object key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user