DATAREDIS-705 - Change return type for set commands from void to Boolean.

Related pull request: #279.
This commit is contained in:
Christoph Strobl
2017-10-02 08:30:14 +02:00
committed by Mark Paluch
parent f5c9e75d97
commit d002445d98
10 changed files with 149 additions and 101 deletions

View File

@@ -913,8 +913,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[])
*/
@Override
public void set(byte[] key, byte[] value) {
delegate.set(key, value);
public Boolean set(byte[] key, byte[] value) {
return delegate.set(key, value);
}
/*
@@ -922,8 +922,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[], org.springframework.data.redis.core.types.Expiration, org.springframework.data.redis.connection.RedisStringCommands.SetOptions)
*/
@Override
public void set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
delegate.set(key, value, expiration, option);
public Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
return delegate.set(key, value, expiration, option);
}
/*
@@ -949,8 +949,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
* @see org.springframework.data.redis.connection.RedisStringCommands#setEx(byte[], long, byte[])
*/
@Override
public void setEx(byte[] key, long seconds, byte[] value) {
delegate.setEx(key, seconds, value);
public Boolean setEx(byte[] key, long seconds, byte[] value) {
return delegate.setEx(key, seconds, value);
}
/*
@@ -958,8 +958,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
* @see org.springframework.data.redis.connection.RedisStringCommands#pSetEx(byte[], long, byte[])
*/
@Override
public void pSetEx(byte[] key, long milliseconds, byte[] value) {
delegate.pSetEx(key, milliseconds, value);
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
return delegate.pSetEx(key, milliseconds, value);
}
/*

View File

@@ -227,15 +227,15 @@ public interface DefaultedRedisConnection extends RedisConnection {
/** @deprecated in favor of {@link RedisConnection#stringCommands()}}. */
@Override
@Deprecated
default void set(byte[] key, byte[] value) {
stringCommands().set(key, value);
default Boolean set(byte[] key, byte[] value) {
return stringCommands().set(key, value);
}
/** @deprecated in favor of {@link RedisConnection#stringCommands()}}. */
@Override
@Deprecated
default void set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
stringCommands().set(key, value, expiration, option);
default Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
return stringCommands().set(key, value, expiration, option);
}
/** @deprecated in favor of {@link RedisConnection#stringCommands()}}. */
@@ -248,15 +248,15 @@ public interface DefaultedRedisConnection extends RedisConnection {
/** @deprecated in favor of {@link RedisConnection#stringCommands()}}. */
@Override
@Deprecated
default void setEx(byte[] key, long seconds, byte[] value) {
stringCommands().setEx(key, seconds, value);
default Boolean setEx(byte[] key, long seconds, byte[] value) {
return stringCommands().setEx(key, seconds, value);
}
/** @deprecated in favor of {@link RedisConnection#stringCommands()}}. */
@Override
@Deprecated
default void pSetEx(byte[] key, long milliseconds, byte[] value) {
stringCommands().pSetEx(key, milliseconds, value);
default Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
return stringCommands().pSetEx(key, milliseconds, value);
}
/** @deprecated in favor of {@link RedisConnection#stringCommands()}}. */

View File

@@ -72,7 +72,7 @@ public interface RedisStringCommands {
* @param value must not be {@literal null}.
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
*/
void set(byte[] key, byte[] value);
Boolean set(byte[] key, byte[] value);
/**
* Set {@code value} for {@code key} applying timeouts from {@code expiration} if set and inserting/updating values
@@ -85,7 +85,7 @@ public interface RedisStringCommands {
* @since 1.7
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
*/
void set(byte[] key, byte[] value, Expiration expiration, SetOption option);
Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption option);
/**
* Set {@code value} for {@code key}, only if {@code key} does not exist.
@@ -106,7 +106,7 @@ public interface RedisStringCommands {
* @param value must not be {@literal null}.
* @see <a href="http://redis.io/commands/setex">Redis Documentation: SETEX</a>
*/
void setEx(byte[] key, long seconds, byte[] value);
Boolean setEx(byte[] key, long seconds, byte[] value);
/**
* Set the {@code value} and expiration in {@code milliseconds} for {@code key}.
@@ -117,7 +117,7 @@ public interface RedisStringCommands {
* @since 1.3
* @see <a href="http://redis.io/commands/psetex">Redis Documentation: PSETEX</a>
*/
void pSetEx(byte[] key, long milliseconds, byte[] value);
Boolean pSetEx(byte[] key, long milliseconds, byte[] value);
/**
* Set multiple keys to multiple values using key-value pairs provided in {@code tuple}.

View File

@@ -193,7 +193,11 @@ abstract public class Converters {
}
public static Boolean stringToBoolean(String s) {
return ObjectUtils.nullSafeEquals("OK", s);
return stringToBooleanConverter().convert(s);
}
public static Converter<String, Boolean> stringToBooleanConverter() {
return (source) -> ObjectUtils.nullSafeEquals("OK", source);
}
public static Converter<String, Properties> stringToProps() {

View File

@@ -24,6 +24,7 @@ import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.redis.connection.ClusterSlotHashUtil;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.connection.jedis.JedisClusterConnection.JedisClusterCommandCallback;
import org.springframework.data.redis.connection.jedis.JedisClusterConnection.JedisMultiKeyClusterCommandCallback;
import org.springframework.data.redis.core.types.Expiration;
@@ -102,13 +103,13 @@ class JedisClusterStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[])
*/
@Override
public void set(byte[] key, byte[] value) {
public Boolean set(byte[] key, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
connection.getCluster().set(key, value);
return Converters.stringToBoolean(connection.getCluster().set(key, value));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -119,7 +120,7 @@ class JedisClusterStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[], org.springframework.data.redis.core.types.Expiration, org.springframework.data.redis.connection.RedisStringCommands.SetOptions)
*/
@Override
public void set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
public Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
@@ -129,7 +130,7 @@ class JedisClusterStringCommands implements RedisStringCommands {
if (expiration == null || expiration.isPersistent()) {
if (option == null || ObjectUtils.nullSafeEquals(SetOption.UPSERT, option)) {
set(key, value);
return set(key, value);
} else {
// BinaryCluster does not support set with nxxx and binary key/value pairs.
@@ -137,16 +138,16 @@ class JedisClusterStringCommands implements RedisStringCommands {
throw new UnsupportedOperationException("Jedis does not support SET XX without PX or EX on BinaryCluster.");
}
setNX(key, value);
return setNX(key, value);
}
} else {
if (option == null || ObjectUtils.nullSafeEquals(SetOption.UPSERT, option)) {
if (ObjectUtils.nullSafeEquals(TimeUnit.MILLISECONDS, expiration.getTimeUnit())) {
pSetEx(key, expiration.getExpirationTime(), value);
return pSetEx(key, expiration.getExpirationTime(), value);
} else {
setEx(key, expiration.getExpirationTime(), value);
return setEx(key, expiration.getExpirationTime(), value);
}
} else {
@@ -154,7 +155,8 @@ class JedisClusterStringCommands implements RedisStringCommands {
byte[] expx = JedisConverters.toSetCommandExPxArgument(expiration);
try {
connection.getCluster().set(key, value, nxxx, expx, expiration.getExpirationTime());
return Converters
.stringToBoolean(connection.getCluster().set(key, value, nxxx, expx, expiration.getExpirationTime()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -184,7 +186,7 @@ class JedisClusterStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#setEx(byte[], long, byte[])
*/
@Override
public void setEx(byte[] key, long seconds, byte[] value) {
public Boolean setEx(byte[] key, long seconds, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
@@ -194,7 +196,7 @@ class JedisClusterStringCommands implements RedisStringCommands {
}
try {
connection.getCluster().setex(key, Long.valueOf(seconds).intValue(), value);
return Converters.stringToBoolean(connection.getCluster().setex(key, Long.valueOf(seconds).intValue(), value));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -205,14 +207,16 @@ class JedisClusterStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#pSetEx(byte[], long, byte[])
*/
@Override
public void pSetEx(byte[] key, long milliseconds, byte[] value) {
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
connection.getClusterCommandExecutor().executeCommandOnSingleNode(
(JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value),
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key));
return Converters.stringToBoolean(connection.getClusterCommandExecutor()
.executeCommandOnSingleNode(
(JedisClusterCommandCallback<String>) client -> client.psetex(key, milliseconds, value),
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
.getValue());
}
/*

View File

@@ -142,6 +142,11 @@ public class JedisConnection extends AbstractRedisConnection {
super(resultHolder);
setStatus(true);
}
public <T> JedisStatusResult(Response<T> resultHolder, Converter<T, ?> converter) {
super(resultHolder, converter);
setStatus(true);
}
}
/**
@@ -647,6 +652,10 @@ public class JedisConnection extends AbstractRedisConnection {
return new JedisStatusResult(response);
}
<T> JedisStatusResult newStatusResult(Response<T> response, Converter<T,?> converter) {
return new JedisStatusResult(response, converter);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.connection.RedisTxCommands#multi()

View File

@@ -23,6 +23,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.connection.jedis.JedisConnection.JedisResult;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.util.Assert;
@@ -118,21 +119,23 @@ class JedisStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[])
*/
@Override
public void set(byte[] key, byte[] value) {
public Boolean set(byte[] key, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newStatusResult(connection.getRequiredPipeline().set(key, value)));
return;
pipeline(connection.newStatusResult(connection.getRequiredPipeline().set(key, value),
Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newStatusResult(connection.getRequiredTransaction().set(key, value)));
return;
transaction(connection.newStatusResult(connection.getRequiredTransaction().set(key, value),
Converters.stringToBooleanConverter()));
return null;
}
connection.getJedis().set(key, value);
return Converters.stringToBoolean(connection.getJedis().set(key, value));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -143,7 +146,7 @@ class JedisStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[], org.springframework.data.redis.core.types.Expiration, org.springframework.data.redis.connection.RedisStringCommands.SetOption)
*/
@Override
public void set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
public Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
@@ -153,7 +156,7 @@ class JedisStringCommands implements RedisStringCommands {
if (expiration.isPersistent()) {
if (ObjectUtils.nullSafeEquals(SetOption.UPSERT, option)) {
set(key, value);
return set(key, value);
} else {
try {
@@ -162,16 +165,18 @@ class JedisStringCommands implements RedisStringCommands {
if (isPipelined()) {
pipeline(connection.newStatusResult(connection.getRequiredPipeline().set(key, value, nxxx)));
return;
pipeline(connection.newStatusResult(connection.getRequiredPipeline().set(key, value, nxxx),
Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newStatusResult(connection.getRequiredTransaction().set(key, value, nxxx)));
return;
transaction(connection.newStatusResult(connection.getRequiredTransaction().set(key, value, nxxx),
Converters.stringToBooleanConverter()));
return null;
}
connection.getJedis().set(key, value, nxxx);
return Converters.stringToBoolean(connection.getJedis().set(key, value, nxxx));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -182,9 +187,9 @@ class JedisStringCommands implements RedisStringCommands {
if (ObjectUtils.nullSafeEquals(SetOption.UPSERT, option)) {
if (ObjectUtils.nullSafeEquals(TimeUnit.MILLISECONDS, expiration.getTimeUnit())) {
pSetEx(key, expiration.getExpirationTime(), value);
return pSetEx(key, expiration.getExpirationTime(), value);
} else {
setEx(key, expiration.getExpirationTime(), value);
return setEx(key, expiration.getExpirationTime(), value);
}
} else {
@@ -201,8 +206,9 @@ class JedisStringCommands implements RedisStringCommands {
}
pipeline(connection.newStatusResult(
connection.getRequiredPipeline().set(key, value, nxxx, expx, (int) expiration.getExpirationTime())));
return;
connection.getRequiredPipeline().set(key, value, nxxx, expx, (int) expiration.getExpirationTime()),
Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
@@ -212,11 +218,13 @@ class JedisStringCommands implements RedisStringCommands {
}
transaction(connection.newStatusResult(
connection.getRequiredTransaction().set(key, value, nxxx, expx, (int) expiration.getExpirationTime())));
return;
connection.getRequiredTransaction().set(key, value, nxxx, expx, (int) expiration.getExpirationTime()),
Converters.stringToBooleanConverter()));
return null;
}
connection.getJedis().set(key, value, nxxx, expx, expiration.getExpirationTime());
return Converters
.stringToBoolean(connection.getJedis().set(key, value, nxxx, expx, expiration.getExpirationTime()));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
@@ -258,7 +266,7 @@ class JedisStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#setEx(byte[], long, byte[])
*/
@Override
public void setEx(byte[] key, long seconds, byte[] value) {
public Boolean setEx(byte[] key, long seconds, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
@@ -269,14 +277,16 @@ class JedisStringCommands implements RedisStringCommands {
try {
if (isPipelined()) {
pipeline(connection.newStatusResult(connection.getRequiredPipeline().setex(key, (int) seconds, value)));
return;
pipeline(connection.newStatusResult(connection.getRequiredPipeline().setex(key, (int) seconds, value),
Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newStatusResult(connection.getRequiredTransaction().setex(key, (int) seconds, value)));
return;
transaction(connection.newStatusResult(connection.getRequiredTransaction().setex(key, (int) seconds, value),
Converters.stringToBooleanConverter()));
return null;
}
connection.getJedis().setex(key, (int) seconds, value);
return Converters.stringToBoolean(connection.getJedis().setex(key, (int) seconds, value));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}
@@ -287,21 +297,23 @@ class JedisStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#pSetEx(byte[], long, byte[])
*/
@Override
public void pSetEx(byte[] key, long milliseconds, byte[] value) {
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newStatusResult(connection.getRequiredPipeline().psetex(key, milliseconds, value)));
return;
pipeline(connection.newStatusResult(connection.getRequiredPipeline().psetex(key, milliseconds, value),
Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newStatusResult(connection.getRequiredTransaction().psetex(key, milliseconds, value)));
return;
transaction(connection.newStatusResult(connection.getRequiredTransaction().psetex(key, milliseconds, value),
Converters.stringToBooleanConverter()));
return null;
}
connection.getJedis().psetex(key, milliseconds, value);
return Converters.stringToBoolean(connection.getJedis().psetex(key, milliseconds, value));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}

View File

@@ -144,16 +144,25 @@ public class LettuceConnection extends AbstractRedisConnection {
private class LettuceStatusResult extends LettuceResult {
@SuppressWarnings("rawtypes")
public LettuceStatusResult(Future resultHolder) {
LettuceStatusResult(Future resultHolder) {
super(resultHolder);
setStatus(true);
}
<T> LettuceStatusResult(Future<T> resultHolder, Converter<T, ?> converter) {
super(resultHolder, converter);
setStatus(true);
}
}
LettuceStatusResult newLettuceStatusResult(Future<?> resultHolder) {
return new LettuceStatusResult(resultHolder);
}
<T> LettuceStatusResult newLettuceStatusResult(Future<T> resultHolder, Converter<T, ?> converter) {
return new LettuceStatusResult(resultHolder, converter);
}
class LettuceTxResult extends FutureResult<Object> {
public LettuceTxResult(Object resultHolder, Converter<?, ?> converter) {
super(resultHolder, converter);
@@ -182,16 +191,25 @@ public class LettuceConnection extends AbstractRedisConnection {
}
private class LettuceTxStatusResult extends LettuceTxResult {
public LettuceTxStatusResult(Object resultHolder) {
LettuceTxStatusResult(Object resultHolder) {
super(resultHolder);
setStatus(true);
}
LettuceTxStatusResult(Object resultHolder, Converter converter) {
super(resultHolder, converter);
setStatus(true);
}
}
LettuceTxStatusResult newLettuceTxStatusResult(Object resultHolder) {
return new LettuceTxStatusResult(resultHolder);
}
LettuceTxStatusResult newLettuceTxStatusResult(Object resultHolder, Converter<?, ?> converter) {
return new LettuceTxStatusResult(resultHolder, converter);
}
private class LettuceTransactionResultConverter<T> extends TransactionResultConverter<T> {
public LettuceTransactionResultConverter(Queue<FutureResult<T>> txResults,
Converter<Exception, DataAccessException> exceptionConverter) {

View File

@@ -26,6 +26,7 @@ import java.util.concurrent.Future;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisStringCommands;
import org.springframework.data.redis.connection.convert.Converters;
import org.springframework.data.redis.connection.lettuce.LettuceConnection.LettuceResult;
import org.springframework.data.redis.connection.lettuce.LettuceConnection.LettuceTxResult;
import org.springframework.data.redis.core.types.Expiration;
@@ -123,21 +124,21 @@ class LettuceStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[])
*/
@Override
public void set(byte[] key, byte[] value) {
public Boolean set(byte[] key, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newLettuceStatusResult(getAsyncConnection().set(key, value)));
return;
pipeline(connection.newLettuceStatusResult(getAsyncConnection().set(key, value), Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newLettuceTxStatusResult(getConnection().set(key, value)));
return;
transaction(connection.newLettuceTxStatusResult(getConnection().set(key, value), Converters.stringToBooleanConverter()));
return null;
}
getConnection().set(key, value);
return Converters.stringToBoolean(getConnection().set(key, value));
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
@@ -148,7 +149,7 @@ class LettuceStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#set(byte[], byte[], org.springframework.data.redis.core.types.Expiration, org.springframework.data.redis.connection.RedisStringCommands.SetOption)
*/
@Override
public void set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
public Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption option) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
@@ -158,15 +159,15 @@ class LettuceStringCommands implements RedisStringCommands {
try {
if (isPipelined()) {
pipeline(connection.newLettuceStatusResult(
getAsyncConnection().set(key, value, LettuceConverters.toSetArgs(expiration, option))));
return;
getAsyncConnection().set(key, value, LettuceConverters.toSetArgs(expiration, option)), Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newLettuceTxStatusResult(
getConnection().set(key, value, LettuceConverters.toSetArgs(expiration, option))));
return;
getConnection().set(key, value, LettuceConverters.toSetArgs(expiration, option)), Converters.stringToBooleanConverter()));
return null;
}
getConnection().set(key, value, LettuceConverters.toSetArgs(expiration, option));
return Converters.stringToBoolean(getConnection().set(key, value, LettuceConverters.toSetArgs(expiration, option)));
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
@@ -202,21 +203,21 @@ class LettuceStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#setEx(byte[], long, byte[])
*/
@Override
public void setEx(byte[] key, long seconds, byte[] value) {
public Boolean setEx(byte[] key, long seconds, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newLettuceStatusResult(getAsyncConnection().setex(key, seconds, value)));
return;
pipeline(connection.newLettuceStatusResult(getAsyncConnection().setex(key, seconds, value), Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newLettuceTxStatusResult(getConnection().setex(key, seconds, value)));
return;
transaction(connection.newLettuceTxStatusResult(getConnection().setex(key, seconds, value), Converters.stringToBooleanConverter()));
return null;
}
getConnection().setex(key, seconds, value);
return Converters.stringToBoolean(getConnection().setex(key, seconds, value));
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}
@@ -227,21 +228,21 @@ class LettuceStringCommands implements RedisStringCommands {
* @see org.springframework.data.redis.connection.RedisStringCommands#pSetEx(byte[], long, byte[])
*/
@Override
public void pSetEx(byte[] key, long milliseconds, byte[] value) {
public Boolean pSetEx(byte[] key, long milliseconds, byte[] value) {
Assert.notNull(key, "Key must not be null!");
Assert.notNull(value, "Value must not be null!");
try {
if (isPipelined()) {
pipeline(connection.newLettuceStatusResult(getAsyncConnection().psetex(key, milliseconds, value)));
return;
pipeline(connection.newLettuceStatusResult(getAsyncConnection().psetex(key, milliseconds, value), Converters.stringToBooleanConverter()));
return null;
}
if (isQueueing()) {
transaction(connection.newLettuceTxStatusResult(getConnection().psetex(key, milliseconds, value)));
return;
transaction(connection.newLettuceTxStatusResult(getConnection().psetex(key, milliseconds, value), Converters.stringToBooleanConverter()));
return null;
}
getConnection().psetex(key, milliseconds, value);
return Converters.stringToBoolean(getConnection().psetex(key, milliseconds, value));
} catch (Exception ex) {
throw convertLettuceAccessException(ex);
}