From 2d049b32cc51e592f8b25f95c271dffc03e34004 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 15 Jun 2023 10:01:54 +0300 Subject: [PATCH] refactoring --- .../org/redisson/RedissonScoredSortedSet.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java b/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java index 69398f424..9d9a90f9d 100644 --- a/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java +++ b/redisson/src/main/java/org/redisson/RedissonScoredSortedSet.java @@ -122,11 +122,7 @@ public class RedissonScoredSortedSet extends RedissonExpirable implements RSc } private RFuture poll(int from, int to, RedisCommand command) { - return poll(getRawName(), from, to, command); - } - - protected RFuture poll(String name, int from, int to, RedisCommand command) { - return commandExecutor.evalWriteAsync(name, codec, command, + return commandExecutor.evalWriteAsync(getRawName(), codec, command, "local v = redis.call('zrange', KEYS[1], ARGV[1], ARGV[2]); " + "if #v > 0 then " + "redis.call('zremrangebyrank', KEYS[1], ARGV[1], ARGV[2]); " @@ -184,18 +180,14 @@ public class RedissonScoredSortedSet extends RedissonExpirable implements RSc } private RFuture pollEntry(int from, int to, RedisCommand command) { - return pollEntry(getRawName(), from, to, command); - } - - protected final RFuture pollEntry(String name, int from, int to, RedisCommand command) { - return commandExecutor.evalWriteAsync(name, codec, command, + return commandExecutor.evalWriteAsync(getRawName(), codec, command, "local v = redis.call('zrange', KEYS[1], ARGV[1], ARGV[2], 'withscores'); " + "if #v > 0 then " + "redis.call('zremrangebyrank', KEYS[1], ARGV[1], ARGV[2]); " + "return v; " + "end " + "return v;", - Collections.singletonList(name), from, to); + Collections.singletonList(getRawName()), from, to); } @Override @@ -1322,7 +1314,8 @@ public class RedissonScoredSortedSet extends RedissonExpirable implements RSc @Override public RFuture revRankAsync(V o) { - return commandExecutor.readAsync(getRawName(), codec, RedisCommands.ZREVRANK_INT, getRawName(), encode(o)); + String name = getRawName(o); + return commandExecutor.readAsync(name, codec, RedisCommands.ZREVRANK_INT, name, encode(o)); } @Override @@ -1332,7 +1325,8 @@ public class RedissonScoredSortedSet extends RedissonExpirable implements RSc @Override public RFuture> revRankEntryAsync(V o) { - return commandExecutor.readAsync(getRawName(), codec, RedisCommands.ZREVRANK_ENTRY, getRawName(), encode(o), "WITHSCORE"); + String name = getRawName(o); + return commandExecutor.readAsync(name, codec, RedisCommands.ZREVRANK_ENTRY, name, encode(o), "WITHSCORE"); } @Override