From a3422bd898b31cea090e4a4fa01caafe3b978590 Mon Sep 17 00:00:00 2001 From: Nykolas Lima Date: Fri, 3 Oct 2014 13:57:34 -0300 Subject: [PATCH 1/2] ttl return -1 if key does not have an associated expire but return -2 if key does not exists --- src/main/java/redis/clients/jedis/Jedis.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index 1f4fcde..49c30c9 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -1,14 +1,21 @@ package redis.clients.jedis; +import java.net.URI; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import redis.clients.jedis.BinaryClient.LIST_POSITION; import redis.clients.util.Pool; import redis.clients.util.SafeEncoder; import redis.clients.util.Slowlog; -import java.net.URI; -import java.util.*; -import java.util.Map.Entry; - public class Jedis extends BinaryJedis implements JedisCommands, MultiKeyCommands, AdvancedJedisCommands, ScriptingCommands, BasicCommands, ClusterCommands { @@ -310,8 +317,9 @@ public class Jedis extends BinaryJedis implements JedisCommands, * * @param key * @return Integer reply, returns the remaining time to live in seconds of a - * key that has an EXPIRE. If the Key does not exists or does not - * have an associated expire, -1 is returned. + * key that has an EXPIRE. + * If the Key does not have an associated expire, -1 is returned. + * If the Key does not exists, -2 is returned. */ public Long ttl(final String key) { checkIsInMulti(); From d7105914aa69c746900d58e1b5a8791299847371 Mon Sep 17 00:00:00 2001 From: Nykolas Lima Date: Fri, 3 Oct 2014 14:23:00 -0300 Subject: [PATCH 2/2] adding information about redis versions --- src/main/java/redis/clients/jedis/Jedis.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index 49c30c9..6ef8b78 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -317,9 +317,11 @@ public class Jedis extends BinaryJedis implements JedisCommands, * * @param key * @return Integer reply, returns the remaining time to live in seconds of a - * key that has an EXPIRE. - * If the Key does not have an associated expire, -1 is returned. - * If the Key does not exists, -2 is returned. + * key that has an EXPIRE. + * In Redis 2.6 or older, if the Key does not exists or does not + * have an associated expire, -1 is returned. + * In Redis 2.8 or newer, if the Key does not have an associated expire, -1 is returned + * or if the Key does not exists, -2 is returned. */ public Long ttl(final String key) { checkIsInMulti();