Feature - add expireAt(Instant) method to RExpirable objects. #3399

pull/3417/head
Nikita Koksharov 4 years ago
parent 7fdbb44158
commit 5793388f10

@ -15,6 +15,7 @@
*/
package org.redisson;
import java.time.Instant;
import java.util.Arrays;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@ -59,7 +60,17 @@ abstract class RedissonExpirable extends RedissonObject implements RExpirable {
@Override
public RFuture<Boolean> expireAtAsync(long timestamp) {
return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.PEXPIREAT, getName(), timestamp);
return expireAtAsync(Instant.ofEpochMilli(timestamp));
}
@Override
public boolean expireAt(Instant instant) {
return get(expireAtAsync(instant));
}
@Override
public RFuture<Boolean> expireAtAsync(Instant instant) {
return commandExecutor.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.PEXPIREAT, getName(), instant.toEpochMilli());
}
@Override

@ -15,6 +15,7 @@
*/
package org.redisson.api;
import java.time.Instant;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@ -38,23 +39,32 @@ public interface RExpirable extends RObject, RExpirableAsync {
boolean expire(long timeToLive, TimeUnit timeUnit);
/**
* Set an expire date for object. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAt(Instant)} instead
*
* @param timestamp - expire date in milliseconds (Unix timestamp)
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
boolean expireAt(long timestamp);
/**
* Set an expire date for object. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAt(Instant)} instead
*
* @param timestamp - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
boolean expireAt(Date timestamp);
/**
* Set an expire date for object. When expire date comes
* the key will automatically be deleted.
*
* @param instant - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
boolean expireAt(Instant instant);
/**
* Clear an expire timeout or expire date for object.
*

@ -15,6 +15,7 @@
*/
package org.redisson.api;
import java.time.Instant;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@ -38,23 +39,32 @@ public interface RExpirableAsync extends RObjectAsync {
RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit);
/**
* Set an expire date for object in async mode. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAtAsync(Instant)} instead
*
* @param timestamp - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
RFuture<Boolean> expireAtAsync(Date timestamp);
/**
* Set an expire date for object in async mode. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAtAsync(Instant)} instead
*
* @param timestamp - expire date in milliseconds (Unix timestamp)
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
RFuture<Boolean> expireAtAsync(long timestamp);
/**
* Set an expire date for object. When expire date comes
* the key will automatically be deleted.
*
* @param instant - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
RFuture<Boolean> expireAtAsync(Instant instant);
/**
* Clear an expire timeout or expire date for object in async mode.
* Object will not be deleted.

@ -15,6 +15,7 @@
*/
package org.redisson.api;
import java.time.Instant;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@ -40,23 +41,32 @@ public interface RExpirableReactive extends RObjectReactive {
Mono<Boolean> expire(long timeToLive, TimeUnit timeUnit);
/**
* Set an expire date for object in mode. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAt(Instant)} instead
*
* @param timestamp - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
Mono<Boolean> expireAt(Date timestamp);
/**
* Set an expire date for object in mode. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAt(Instant)} instead
*
* @param timestamp - expire date in milliseconds (Unix timestamp)
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
Mono<Boolean> expireAt(long timestamp);
/**
* Set an expire date for object. When expire date comes
* the key will automatically be deleted.
*
* @param instant - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
Mono<Boolean> expireAt(Instant instant);
/**
* Clear an expire timeout or expire date for object in mode.
* Object will not be deleted.

@ -15,6 +15,7 @@
*/
package org.redisson.api;
import java.time.Instant;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@ -40,23 +41,32 @@ public interface RExpirableRx extends RObjectRx {
Single<Boolean> expire(long timeToLive, TimeUnit timeUnit);
/**
* Set an expire date for object in mode. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAt(Instant)} instead
*
* @param timestamp - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
Single<Boolean> expireAt(Date timestamp);
/**
* Set an expire date for object in mode. When expire date comes
* the key will automatically be deleted.
* Use {@link #expireAt(Instant)} instead
*
* @param timestamp - expire date in milliseconds (Unix timestamp)
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
@Deprecated
Single<Boolean> expireAt(long timestamp);
/**
* Set an expire date for object. When expire date comes
* the key will automatically be deleted.
*
* @param instant - expire date
* @return <code>true</code> if the timeout was set and <code>false</code> if not
*/
Single<Boolean> expireAt(Instant instant);
/**
* Clear an expire timeout or expire date for object in mode.
* Object will not be deleted.

Loading…
Cancel
Save