refactoring

pull/968/head
Nikita 8 years ago
parent 2cbf326f6a
commit d34dc2cc63

@ -56,22 +56,22 @@ public class RedissonBucket<V> extends RedissonExpirable implements RBucket<V> {
}
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.<Object>singletonList(getName()), expect);
Collections.<Object>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.<Object>singletonList(getName()), expect, update);
Collections.<Object>singletonList(getName()), encode(expect), encode(update));
}
@Override
@ -123,7 +123,7 @@ public class RedissonBucket<V> extends RedissonExpirable implements RBucket<V> {
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<V> extends RedissonExpirable implements RBucket<V> {
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<V> extends RedissonExpirable implements RBucket<V> {
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<V> extends RedissonExpirable implements RBucket<V> {
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

@ -281,10 +281,10 @@ public interface RedisCommands {
RedisCommand<Object> GETRANGE = new RedisCommand<Object>("GETRANGE");
RedisCommand<Object> APPEND = new RedisCommand<Object>("APPEND");
RedisCommand<Object> SETRANGE = new RedisCommand<Object>("SETRANGE");
RedisCommand<Void> SET = new RedisCommand<Void>("SET", new VoidReplayConvertor(), 2);
RedisCommand<Boolean> SETPXNX = new RedisCommand<Boolean>("SET", new BooleanNotNullReplayConvertor(), 2);
RedisCommand<Boolean> SETNX = new RedisCommand<Boolean>("SETNX", new BooleanReplayConvertor(), 2);
RedisCommand<Void> PSETEX = new RedisCommand<Void>("PSETEX", new VoidReplayConvertor(), 3);
RedisCommand<Void> SET = new RedisCommand<Void>("SET", new VoidReplayConvertor());
RedisCommand<Boolean> SETPXNX = new RedisCommand<Boolean>("SET", new BooleanNotNullReplayConvertor());
RedisCommand<Boolean> SETNX = new RedisCommand<Boolean>("SETNX", new BooleanReplayConvertor());
RedisCommand<Void> PSETEX = new RedisCommand<Void>("PSETEX", new VoidReplayConvertor());
RedisStrictCommand<Long> TOUCH_LONG = new RedisStrictCommand<Long>("TOUCH");
RedisStrictCommand<Boolean> TOUCH = new RedisStrictCommand<Boolean>("TOUCH", new BooleanReplayConvertor());

Loading…
Cancel
Save