refactoring

pull/6384/head
Nikita Koksharov 3 weeks ago
parent 5dd631caad
commit 4d73d8d97d

@ -17,13 +17,13 @@ package org.redisson.eviction;
import io.netty.util.Timeout;
import io.netty.util.TimerTask;
import org.redisson.api.RFuture;
import org.redisson.command.CommandAsyncExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Deque;
import java.util.LinkedList;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
/**
@ -63,7 +63,7 @@ abstract class EvictionTask implements TimerTask {
timeout.cancel();
}
abstract RFuture<Integer> execute();
abstract CompletionStage<Integer> execute();
abstract String getName();
@ -72,8 +72,8 @@ abstract class EvictionTask implements TimerTask {
if (executor.getServiceManager().isShuttingDown()) {
return;
}
RFuture<Integer> future = execute();
CompletionStage<Integer> future = execute();
future.whenComplete((size, e) -> {
if (e != null) {
log.error("Unable to evict elements for '{}'", getName(), e);

@ -15,13 +15,13 @@
*/
package org.redisson.eviction;
import java.util.Arrays;
import org.redisson.api.RFuture;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandAsyncExecutor;
import java.util.Arrays;
import java.util.concurrent.CompletionStage;
/**
*
* @author Nikita Koksharov
@ -46,7 +46,7 @@ public class JCacheEvictionTask extends EvictionTask {
}
@Override
RFuture<Integer> execute() {
CompletionStage<Integer> execute() {
return executor.evalWriteAsync(name, LongCodec.INSTANCE, RedisCommands.EVAL_INTEGER,
"local expiredKeys = redis.call('zrangebyscore', KEYS[2], 0, ARGV[1], 'limit', 0, ARGV[2]); "
+ "for i, k in ipairs(expiredKeys) do "

@ -67,7 +67,7 @@ public class MapCacheEvictionTask extends EvictionTask {
}
@Override
RFuture<Integer> execute() {
CompletionStage<Integer> execute() {
int latchExpireTime = Math.min(delay, 30);
RFuture<Integer> expiredFuture = executor.evalWriteNoRetryAsync(name, LongCodec.INSTANCE, RedisCommands.EVAL_INTEGER,
"if redis.call('setnx', KEYS[6], ARGV[4]) == 0 then "

@ -15,13 +15,13 @@
*/
package org.redisson.eviction;
import java.util.Arrays;
import org.redisson.api.RFuture;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandAsyncExecutor;
import java.util.Arrays;
import java.util.concurrent.CompletionStage;
/**
*
* @author Nikita Koksharov
@ -42,8 +42,8 @@ public class MultimapEvictionTask extends EvictionTask {
String getName() {
return name;
}
RFuture<Integer> execute() {
CompletionStage<Integer> execute() {
return executor.evalWriteAsync(name, LongCodec.INSTANCE, RedisCommands.EVAL_INTEGER,
"local expiredKeys = redis.call('zrangebyscore', KEYS[2], 0, ARGV[1], 'limit', 0, ARGV[2]); "
+ "if #expiredKeys > 0 then "

@ -15,11 +15,12 @@
*/
package org.redisson.eviction;
import org.redisson.api.RFuture;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandAsyncExecutor;
import java.util.concurrent.CompletionStage;
/**
*
* @author Nikita Koksharov
@ -42,7 +43,7 @@ public class ScoredSetEvictionTask extends EvictionTask {
}
@Override
RFuture<Integer> execute() {
CompletionStage<Integer> execute() {
return executor.writeAsync(name, LongCodec.INSTANCE, RedisCommands.ZREMRANGEBYSCORE, name, 0, System.currentTimeMillis() - shiftInMilliseconds);
}

@ -15,12 +15,12 @@
*/
package org.redisson.eviction;
import org.redisson.api.RFuture;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandAsyncExecutor;
import java.util.Arrays;
import java.util.concurrent.CompletionStage;
/**
*
@ -39,7 +39,7 @@ public class TimeSeriesEvictionTask extends EvictionTask {
}
@Override
RFuture<Integer> execute() {
CompletionStage<Integer> execute() {
return executor.evalWriteAsync(name, LongCodec.INSTANCE, RedisCommands.EVAL_INTEGER,
"local expiredKeys = redis.call('zrangebyscore', KEYS[2], 0, ARGV[1], 'limit', 0, ARGV[2]); "
+ "if #expiredKeys > 0 then "

Loading…
Cancel
Save