DATAREDIS-286 - Avoid overflow in JedisConnection#expire / #pexpire.
Workaround Jedis issue https://github.com/xetorthio/jedis/pull/575. We now delegate calls to expire(...) to pExpireAt(...) in case the seconds parameter is > than Integer.MAX_VALUE. We query the server time to compute the new expiration date. Original pull request: #52.
This commit is contained in:
committed by
Christoph Strobl
parent
408b52a449
commit
59582f1910
@@ -26,6 +26,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -737,6 +738,18 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
public Boolean expire(byte[] key, long seconds) {
|
||||
|
||||
/*
|
||||
* @see DATAREDIS-286 to avoid overflow in Jedis
|
||||
*
|
||||
* TODO Remove this workaround when we upgrade to a Jedis version that contains a
|
||||
* fix for: https://github.com/xetorthio/jedis/pull/575
|
||||
*/
|
||||
if (seconds > Integer.MAX_VALUE) {
|
||||
|
||||
return pExpireAt(key, time() + TimeUnit.SECONDS.toMillis(seconds));
|
||||
}
|
||||
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new JedisResult(pipeline.expire(key, (int) seconds), JedisConverters.longToBoolean()));
|
||||
@@ -912,6 +925,18 @@ public class JedisConnection implements RedisConnection {
|
||||
}
|
||||
|
||||
public Boolean pExpire(byte[] key, long millis) {
|
||||
|
||||
/*
|
||||
* @see DATAREDIS-286 to avoid overflow in Jedis
|
||||
*
|
||||
* TODO Remove this workaround when we upgrade to a Jedis version that contains a
|
||||
* fix for: https://github.com/xetorthio/jedis/pull/575
|
||||
*/
|
||||
if (millis > Integer.MAX_VALUE) {
|
||||
|
||||
return pExpireAt(key, time() + millis);
|
||||
}
|
||||
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new JedisResult(pipeline.pexpire(key, (int) millis), JedisConverters.longToBoolean()));
|
||||
|
||||
Reference in New Issue
Block a user