diff --git a/src/main/java/org/redisson/RedissonExpirable.java b/src/main/java/org/redisson/RedissonExpirable.java index 40587e574..07a7efc7a 100644 --- a/src/main/java/org/redisson/RedissonExpirable.java +++ b/src/main/java/org/redisson/RedissonExpirable.java @@ -43,7 +43,7 @@ abstract class RedissonExpirable extends RedissonObject implements RExpirable { @Override public Future expireAsync(long timeToLive, TimeUnit timeUnit) { - return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.EXPIRE, getName(), timeUnit.toSeconds(timeToLive)); + return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.PEXPIRE, getName(), timeUnit.toSeconds(timeToLive)); } @Override @@ -53,7 +53,7 @@ abstract class RedissonExpirable extends RedissonObject implements RExpirable { @Override public Future expireAtAsync(long timestamp) { - return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.EXPIREAT, getName(), timestamp); + return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.PEXPIREAT, getName(), timestamp); } @Override @@ -83,7 +83,7 @@ abstract class RedissonExpirable extends RedissonObject implements RExpirable { @Override public Future remainTimeToLiveAsync() { - return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.TTL, getName()); + return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.PTTL, getName()); } } diff --git a/src/main/java/org/redisson/api/RExpirableReactive.java b/src/main/java/org/redisson/api/RExpirableReactive.java index fd71ee590..5c6e4c25c 100644 --- a/src/main/java/org/redisson/api/RExpirableReactive.java +++ b/src/main/java/org/redisson/api/RExpirableReactive.java @@ -52,7 +52,7 @@ public interface RExpirableReactive extends RObjectReactive { * Set an expire date for object in mode. When expire date comes * the key will automatically be deleted. * - * @param timestamp - expire date in seconds (Unix timestamp) + * @param timestamp - expire date in milliseconds (Unix timestamp) * @return true if the timeout was set and false if not */ Publisher expireAt(long timestamp); @@ -66,9 +66,11 @@ public interface RExpirableReactive extends RObjectReactive { Publisher clearExpire(); /** - * Get remaining time to live of object in seconds. + * Get remaining time to live of object in milliseconds. * - * @return -1 if object does not exist or time in seconds + * @return time in milliseconds + * -2 if the key does not exist. + * -1 if the key exists but has no associated expire. */ Publisher remainTimeToLive(); diff --git a/src/main/java/org/redisson/client/protocol/RedisCommands.java b/src/main/java/org/redisson/client/protocol/RedisCommands.java index 0f0a2c00b..54a554576 100644 --- a/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -117,10 +117,10 @@ public interface RedisCommands { RedisStrictCommand LLEN = new RedisStrictCommand("LLEN"); RedisStrictCommand LTRIM = new RedisStrictCommand("LTRIM", new BooleanReplayConvertor()); - RedisStrictCommand EXPIRE = new RedisStrictCommand("EXPIRE", new BooleanReplayConvertor()); - RedisStrictCommand EXPIREAT = new RedisStrictCommand("EXPIREAT", new BooleanReplayConvertor()); + RedisStrictCommand PEXPIRE = new RedisStrictCommand("PEXPIRE", new BooleanReplayConvertor()); + RedisStrictCommand PEXPIREAT = new RedisStrictCommand("PEXPIREAT", new BooleanReplayConvertor()); RedisStrictCommand PERSIST = new RedisStrictCommand("PERSIST", new BooleanReplayConvertor()); - RedisStrictCommand TTL = new RedisStrictCommand("TTL"); + RedisStrictCommand PTTL = new RedisStrictCommand("PTTL"); RedisCommand RPOPLPUSH = new RedisCommand("RPOPLPUSH"); RedisCommand BRPOPLPUSH = new RedisCommand("BRPOPLPUSH"); diff --git a/src/main/java/org/redisson/core/RExpirable.java b/src/main/java/org/redisson/core/RExpirable.java index a8ac1e476..929372a7e 100644 --- a/src/main/java/org/redisson/core/RExpirable.java +++ b/src/main/java/org/redisson/core/RExpirable.java @@ -41,7 +41,7 @@ public interface RExpirable extends RObject, RExpirableAsync { * Set an expire date for object. When expire date comes * the key will automatically be deleted. * - * @param timestamp - expire date in seconds (Unix timestamp) + * @param timestamp - expire date in milliseconds (Unix timestamp) * @return true if the timeout was set and false if not */ boolean expireAt(long timestamp); @@ -66,7 +66,7 @@ public interface RExpirable extends RObject, RExpirableAsync { /** * Remaining time to live of Redisson object that has a timeout * - * @return time in seconds + * @return time in milliseconds * -2 if the key does not exist. * -1 if the key exists but has no associated expire. */ diff --git a/src/main/java/org/redisson/reactive/RedissonExpirableReactive.java b/src/main/java/org/redisson/reactive/RedissonExpirableReactive.java index e6147743c..21b129125 100644 --- a/src/main/java/org/redisson/reactive/RedissonExpirableReactive.java +++ b/src/main/java/org/redisson/reactive/RedissonExpirableReactive.java @@ -38,17 +38,17 @@ abstract class RedissonExpirableReactive extends RedissonObjectReactive implemen @Override public Publisher expire(long timeToLive, TimeUnit timeUnit) { - return commandExecutor.writeReactive(getName(), StringCodec.INSTANCE, RedisCommands.EXPIRE, getName(), timeUnit.toSeconds(timeToLive)); + return commandExecutor.writeReactive(getName(), StringCodec.INSTANCE, RedisCommands.PEXPIRE, getName(), timeUnit.toSeconds(timeToLive)); } @Override public Publisher expireAt(long timestamp) { - return commandExecutor.writeReactive(getName(), StringCodec.INSTANCE, RedisCommands.EXPIREAT, getName(), timestamp); + return commandExecutor.writeReactive(getName(), StringCodec.INSTANCE, RedisCommands.PEXPIREAT, getName(), timestamp); } @Override public Publisher expireAt(Date timestamp) { - return expireAt(timestamp.getTime() / 1000); + return expireAt(timestamp.getTime()); } @Override @@ -58,7 +58,7 @@ abstract class RedissonExpirableReactive extends RedissonObjectReactive implemen @Override public Publisher remainTimeToLive() { - return commandExecutor.readReactive(getName(), StringCodec.INSTANCE, RedisCommands.TTL, getName()); + return commandExecutor.readReactive(getName(), StringCodec.INSTANCE, RedisCommands.PTTL, getName()); } }