From 48b3b085ff1a1dfc46646023cf7d70f5fbb72c28 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Fri, 26 Jul 2024 09:03:54 +0300 Subject: [PATCH] refactoring --- .../src/main/java/org/redisson/RedissonObject.java | 12 +++++------- .../test/java/org/redisson/RedissonBucketTest.java | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonObject.java b/redisson/src/main/java/org/redisson/RedissonObject.java index c01e32a80..96e95c571 100644 --- a/redisson/src/main/java/org/redisson/RedissonObject.java +++ b/redisson/src/main/java/org/redisson/RedissonObject.java @@ -167,13 +167,11 @@ public abstract class RedissonObject implements RObject { if (getServiceManager().getCfg().isClusterConfig()) { checkNotBatch(); - RFuture r = commandExecutor.evalWriteAsync(getRawName(), ByteArrayCodec.INSTANCE, RedisCommands.EVAL_OBJECT, - "local result = redis.call('dump', KEYS[1]);" + - "redis.call('del', KEYS[1]);" + - "return result;", - Arrays.asList(getRawName())); - CompletionStage f = r.thenCompose(val -> commandExecutor.writeAsync(getRawName(), StringCodec.INSTANCE, RedisCommands.RESTORE, mapName(newName), 0, val)) - .thenAccept(rr -> setName(newName)); + String nn = mapName(newName); + CompletionStage f = dumpAsync() + .thenCompose(val -> commandExecutor.writeAsync(nn, StringCodec.INSTANCE, RedisCommands.RESTORE, nn, 0, val)) + .thenAccept(rr -> setName(newName)) + .thenCompose(val -> deleteAsync().thenApply(r -> null)); return new CompletableFutureWrapper<>(f); } diff --git a/redisson/src/test/java/org/redisson/RedissonBucketTest.java b/redisson/src/test/java/org/redisson/RedissonBucketTest.java index 2bc939240..c8a2e7178 100755 --- a/redisson/src/test/java/org/redisson/RedissonBucketTest.java +++ b/redisson/src/test/java/org/redisson/RedissonBucketTest.java @@ -127,6 +127,8 @@ public class RedissonBucketTest extends RedisDockerTest { RBucket bs = rc.getBucket(b.getName()); assertThat(bs.get()).isEqualTo("123"); + + assertThat(rc.getKeys().count()).isEqualTo(1); }); }