From d34dc2cc639d4f68cb8d86d9f3a89786d050931a Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 6 Jul 2017 12:43:29 +0300 Subject: [PATCH] refactoring --- .../main/java/org/redisson/RedissonBucket.java | 16 ++++++++-------- .../redisson/client/protocol/RedisCommands.java | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonBucket.java b/redisson/src/main/java/org/redisson/RedissonBucket.java index 608ef8b82..9661d1636 100644 --- a/redisson/src/main/java/org/redisson/RedissonBucket.java +++ b/redisson/src/main/java/org/redisson/RedissonBucket.java @@ -56,22 +56,22 @@ public class RedissonBucket extends RedissonExpirable implements RBucket { } if (update == null) { - return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN_WITH_VALUES, + return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('get', KEYS[1]) == ARGV[1] then " + "redis.call('del', KEYS[1]); " + "return 1 " + "else " + "return 0 end", - Collections.singletonList(getName()), expect); + Collections.singletonList(getName()), encode(expect)); } - return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN_WITH_VALUES, + return commandExecutor.evalWriteAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('get', KEYS[1]) == ARGV[1] then " + "redis.call('set', KEYS[1], ARGV[2]); " + "return 1 " + "else " + "return 0 end", - Collections.singletonList(getName()), expect, update); + Collections.singletonList(getName()), encode(expect), encode(update)); } @Override @@ -123,7 +123,7 @@ public class RedissonBucket extends RedissonExpirable implements RBucket { return commandExecutor.writeAsync(getName(), RedisCommands.DEL_VOID, getName()); } - return commandExecutor.writeAsync(getName(), codec, RedisCommands.SET, getName(), value); + return commandExecutor.writeAsync(getName(), codec, RedisCommands.SET, getName(), encode(value)); } @Override @@ -137,7 +137,7 @@ public class RedissonBucket extends RedissonExpirable implements RBucket { throw new IllegalArgumentException("Value can't be null"); } - return commandExecutor.writeAsync(getName(), codec, RedisCommands.PSETEX, getName(), timeUnit.toMillis(timeToLive), value); + return commandExecutor.writeAsync(getName(), codec, RedisCommands.PSETEX, getName(), timeUnit.toMillis(timeToLive), encode(value)); } @Override @@ -146,7 +146,7 @@ public class RedissonBucket extends RedissonExpirable implements RBucket { return commandExecutor.readAsync(getName(), codec, RedisCommands.NOT_EXISTS, getName()); } - return commandExecutor.writeAsync(getName(), codec, RedisCommands.SETNX, getName(), value); + return commandExecutor.writeAsync(getName(), codec, RedisCommands.SETNX, getName(), encode(value)); } @Override @@ -154,7 +154,7 @@ public class RedissonBucket extends RedissonExpirable implements RBucket { if (value == null) { throw new IllegalArgumentException("Value can't be null"); } - return commandExecutor.writeAsync(getName(), codec, RedisCommands.SETPXNX, getName(), value, "PX", timeUnit.toMillis(timeToLive), "NX"); + return commandExecutor.writeAsync(getName(), codec, RedisCommands.SETPXNX, getName(), encode(value), "PX", timeUnit.toMillis(timeToLive), "NX"); } @Override diff --git a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java index 921688465..322407bcb 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -281,10 +281,10 @@ public interface RedisCommands { RedisCommand GETRANGE = new RedisCommand("GETRANGE"); RedisCommand APPEND = new RedisCommand("APPEND"); RedisCommand SETRANGE = new RedisCommand("SETRANGE"); - RedisCommand SET = new RedisCommand("SET", new VoidReplayConvertor(), 2); - RedisCommand SETPXNX = new RedisCommand("SET", new BooleanNotNullReplayConvertor(), 2); - RedisCommand SETNX = new RedisCommand("SETNX", new BooleanReplayConvertor(), 2); - RedisCommand PSETEX = new RedisCommand("PSETEX", new VoidReplayConvertor(), 3); + RedisCommand SET = new RedisCommand("SET", new VoidReplayConvertor()); + RedisCommand SETPXNX = new RedisCommand("SET", new BooleanNotNullReplayConvertor()); + RedisCommand SETNX = new RedisCommand("SETNX", new BooleanReplayConvertor()); + RedisCommand PSETEX = new RedisCommand("PSETEX", new VoidReplayConvertor()); RedisStrictCommand TOUCH_LONG = new RedisStrictCommand("TOUCH"); RedisStrictCommand TOUCH = new RedisStrictCommand("TOUCH", new BooleanReplayConvertor());