|
|
|
@ -23,6 +23,8 @@ import org.redisson.client.protocol.StringCodec;
|
|
|
|
|
import org.redisson.connection.ConnectionManager;
|
|
|
|
|
import org.redisson.core.RExpirable;
|
|
|
|
|
|
|
|
|
|
import io.netty.util.concurrent.Future;
|
|
|
|
|
|
|
|
|
|
abstract class RedissonExpirable extends RedissonObject implements RExpirable {
|
|
|
|
|
|
|
|
|
|
RedissonExpirable(ConnectionManager connectionManager, String name) {
|
|
|
|
@ -30,28 +32,53 @@ abstract class RedissonExpirable extends RedissonObject implements RExpirable {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean expire(final long timeToLive, final TimeUnit timeUnit) {
|
|
|
|
|
return connectionManager.write(getName(), StringCodec.INSTANCE, RedisCommands.EXPIRE, getName(), timeUnit.toSeconds(timeToLive));
|
|
|
|
|
public boolean expire(long timeToLive, TimeUnit timeUnit) {
|
|
|
|
|
return connectionManager.get(expireAsync(timeToLive, timeUnit));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Future<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit) {
|
|
|
|
|
return connectionManager.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.EXPIRE, getName(), timeUnit.toSeconds(timeToLive));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean expireAt(final long timestamp) {
|
|
|
|
|
return connectionManager.write(getName(), StringCodec.INSTANCE, RedisCommands.EXPIREAT, getName(), timestamp);
|
|
|
|
|
public boolean expireAt(long timestamp) {
|
|
|
|
|
return connectionManager.get(expireAtAsync(timestamp));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean expireAt(final Date timestamp) {
|
|
|
|
|
public Future<Boolean> expireAtAsync(long timestamp) {
|
|
|
|
|
return connectionManager.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.EXPIREAT, getName(), timestamp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean expireAt(Date timestamp) {
|
|
|
|
|
return expireAt(timestamp.getTime() / 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Future<Boolean> expireAtAsync(Date timestamp) {
|
|
|
|
|
return expireAtAsync(timestamp.getTime() / 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean clearExpire() {
|
|
|
|
|
return connectionManager.write(getName(), StringCodec.INSTANCE, RedisCommands.PERSIST, getName());
|
|
|
|
|
return connectionManager.get(clearExpireAsync());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Future<Boolean> clearExpireAsync() {
|
|
|
|
|
return connectionManager.writeAsync(getName(), StringCodec.INSTANCE, RedisCommands.PERSIST, getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public long remainTimeToLive() {
|
|
|
|
|
return connectionManager.write(getName(), StringCodec.INSTANCE, RedisCommands.TTL, getName());
|
|
|
|
|
return connectionManager.get(remainTimeToLiveAsync());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Future<Long> remainTimeToLiveAsync() {
|
|
|
|
|
return connectionManager.readAsync(getName(), StringCodec.INSTANCE, RedisCommands.TTL, getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|