Fixed - RExpirable.expire(Instant) method doesn't work for RBloomFilter, RBoundedBlockingQueue, RDelayedQueue, RLock, RIdGenerator, RMultimap, RMapCache, RPriorityQueue, RRateLimiter, RReliableTopic, RSetMultimap, RTimeSeries objects. #3660

pull/3676/head
Nikita Koksharov 4 years ago
parent f587a6e481
commit bd329099ff

@ -43,6 +43,7 @@ import org.redisson.command.CommandBatchService;
import org.redisson.misc.Hash; import org.redisson.misc.Hash;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -289,8 +290,8 @@ public class RedissonBloomFilter<T> extends RedissonExpirable implements RBloomF
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), configName); return super.expireAtAsync(timestamp, getRawName(), configName);
} }
@Override @Override

@ -368,8 +368,8 @@ public class RedissonBoundedBlockingQueue<V> extends RedissonQueue<V> implements
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), getSemaphoreName()); return super.expireAtAsync(timestamp, getRawName(), getSemaphoreName());
} }
@Override @Override

@ -440,8 +440,8 @@ public class RedissonDelayedQueue<V> extends RedissonExpirable implements RDelay
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, queueName, timeoutSetName); return super.expireAtAsync(timestamp, queueName, timeoutSetName);
} }
@Override @Override

@ -70,7 +70,7 @@ abstract class RedissonExpirable extends RedissonObject implements RExpirable {
@Override @Override
public RFuture<Boolean> expireAsync(Instant instant) { public RFuture<Boolean> expireAsync(Instant instant) {
return commandExecutor.writeAsync(getRawName(), StringCodec.INSTANCE, RedisCommands.PEXPIREAT, getRawName(), instant.toEpochMilli()); return expireAtAsync(instant.toEpochMilli(), getRawName());
} }
@Override @Override

@ -297,8 +297,8 @@ public class RedissonFairLock extends RedissonLock implements RLock {
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), threadsQueueName, timeoutSetName); return super.expireAtAsync(timestamp, getRawName(), threadsQueueName, timeoutSetName);
} }
@Override @Override

@ -160,8 +160,8 @@ public class RedissonIdGenerator extends RedissonExpirable implements RIdGenerat
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), getAllocationSizeName()); return super.expireAtAsync(timestamp, getRawName(), getAllocationSizeName());
} }
@Override @Override

@ -15,6 +15,7 @@
*/ */
package org.redisson; package org.redisson;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -240,6 +241,11 @@ public class RedissonListMultimap<K, V> extends RedissonMultimap<K, V> implement
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
} }
@Override
public RFuture<Boolean> expireAsync(Instant instant) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
}
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { public RFuture<Boolean> expireAtAsync(long timestamp) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");

@ -15,6 +15,7 @@
*/ */
package org.redisson; package org.redisson;
import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -202,6 +203,11 @@ public class RedissonListMultimapCache<K, V> extends RedissonListMultimap<K, V>
return baseCache.deleteAsync(); return baseCache.deleteAsync();
} }
@Override
public RFuture<Boolean> expireAsync(Instant instant) {
return expireAtAsync(instant.toEpochMilli());
}
@Override @Override
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit) { public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit) {
return baseCache.expireAsync(timeToLive, timeUnit); return baseCache.expireAsync(timeToLive, timeUnit);

@ -15,6 +15,7 @@
*/ */
package org.redisson; package org.redisson;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -72,6 +73,11 @@ public class RedissonListMultimapValues<V> extends RedissonExpirable implements
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
} }
@Override
public RFuture<Boolean> expireAsync(Instant instant) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
}
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { public RFuture<Boolean> expireAtAsync(long timestamp) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");

@ -2416,7 +2416,7 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return commandExecutor.evalWriteAsync(getRawName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, return commandExecutor.evalWriteAsync(getRawName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN,
"local maxSize = tonumber(redis.call('hget', KEYS[5], 'max-size')); " + "local maxSize = tonumber(redis.call('hget', KEYS[5], 'max-size')); " +
"if maxSize ~= nil and maxSize ~= 0 then " + "if maxSize ~= nil and maxSize ~= 0 then " +

@ -344,7 +344,7 @@ public abstract class RedissonMultimap<K, V> extends RedissonExpirable implement
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return commandExecutor.evalWriteAsync(getRawName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN, return commandExecutor.evalWriteAsync(getRawName(), LongCodec.INSTANCE, RedisCommands.EVAL_BOOLEAN,
"local entries = redis.call('hgetall', KEYS[1]); " + "local entries = redis.call('hgetall', KEYS[1]); " +
"for i, v in ipairs(entries) do " + "for i, v in ipairs(entries) do " +

@ -606,8 +606,8 @@ public class RedissonPermitExpirableSemaphore extends RedissonExpirable implemen
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), timeoutName); return super.expireAtAsync(timestamp, getRawName(), timeoutName);
} }
@Override @Override

@ -429,8 +429,8 @@ public class RedissonPriorityQueue<V> extends RedissonList<V> implements RPriori
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), getComparatorKeyName()); return super.expireAtAsync(timestamp, getRawName(), getComparatorKeyName());
} }
@Override @Override

@ -336,8 +336,8 @@ public class RedissonRateLimiter extends RedissonExpirable implements RRateLimit
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), getValueName(), getClientValueName(), getPermitsName(), getClientPermitsName()); return super.expireAtAsync(timestamp, getRawName(), getValueName(), getClientValueName(), getPermitsName(), getClientPermitsName());
} }
@Override @Override

@ -282,8 +282,8 @@ public class RedissonReliableTopic extends RedissonExpirable implements RReliabl
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), getSubscribersName(), getMapName(), getCounter(), getTimeout()); return super.expireAtAsync(timestamp, getRawName(), getSubscribersName(), getMapName(), getCounter(), getTimeout());
} }
@Override @Override

@ -15,6 +15,7 @@
*/ */
package org.redisson; package org.redisson;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -219,6 +220,11 @@ public class RedissonSetMultimap<K, V> extends RedissonMultimap<K, V> implements
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
} }
@Override
public RFuture<Boolean> expireAsync(Instant instant) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
}
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { public RFuture<Boolean> expireAtAsync(long timestamp) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");

@ -15,6 +15,7 @@
*/ */
package org.redisson; package org.redisson;
import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -195,6 +196,11 @@ public class RedissonSetMultimapCache<K, V> extends RedissonSetMultimap<K, V> im
return baseCache.deleteAsync(); return baseCache.deleteAsync();
} }
@Override
public RFuture<Boolean> expireAsync(Instant instant) {
return expireAtAsync(instant.toEpochMilli());
}
@Override @Override
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit) { public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit) {
return baseCache.expireAsync(timeToLive, timeUnit); return baseCache.expireAsync(timeToLive, timeUnit);

@ -15,6 +15,7 @@
*/ */
package org.redisson; package org.redisson;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -89,6 +90,11 @@ public class RedissonSetMultimapValues<V> extends RedissonExpirable implements R
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
} }
@Override
public RFuture<Boolean> expireAsync(Instant instant) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");
}
@Override @Override
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit) { public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit) {
throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set"); throw new UnsupportedOperationException("This operation is not supported for SetMultimap values Set");

@ -563,8 +563,8 @@ public class RedissonTimeSeries<V> extends RedissonExpirable implements RTimeSer
} }
@Override @Override
public RFuture<Boolean> expireAtAsync(long timestamp) { protected RFuture<Boolean> expireAtAsync(long timestamp, String... keys) {
return expireAtAsync(timestamp, getRawName(), getTimeoutSetName()); return super.expireAtAsync(timestamp, getRawName(), getTimeoutSetName());
} }
@Override @Override

@ -4,6 +4,8 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.redisson.api.RBloomFilter; import org.redisson.api.RBloomFilter;
import java.time.Instant;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
public class RedissonBloomFilterTest extends BaseTest { public class RedissonBloomFilterTest extends BaseTest {
@ -63,6 +65,19 @@ public class RedissonBloomFilterTest extends BaseTest {
} }
@Test
public void testExpire() throws InterruptedException {
RBloomFilter<String> filter = redisson.getBloomFilter("filter");
filter.tryInit(55000000L, 0.03);
filter.add("test");
filter.expire(Instant.now().plusSeconds(2));
Thread.sleep(2100);
assertThat(redisson.getKeys().count()).isZero();
}
@Test @Test
public void testNotInitializedOnContains() { public void testNotInitializedOnContains() {
Assertions.assertThrows(IllegalStateException.class, () -> { Assertions.assertThrows(IllegalStateException.class, () -> {

Loading…
Cancel
Save