From b42191bfea5167b787198cde242396659315bee4 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 15 Jul 2015 16:39:41 +0300 Subject: [PATCH] LongReplayDecoder replaced with LongReplayConvertor --- src/main/java/org/redisson/RedissonMap.java | 9 ++++----- ...layDecoder.java => LongReplayConvertor.java} | 17 +++++------------ 2 files changed, 9 insertions(+), 17 deletions(-) rename src/main/java/org/redisson/client/protocol/{decoder/LongReplayDecoder.java => LongReplayConvertor.java} (63%) diff --git a/src/main/java/org/redisson/RedissonMap.java b/src/main/java/org/redisson/RedissonMap.java index e68aea805..b62329b0a 100644 --- a/src/main/java/org/redisson/RedissonMap.java +++ b/src/main/java/org/redisson/RedissonMap.java @@ -29,11 +29,11 @@ import java.util.NoSuchElementException; import java.util.Set; import org.redisson.client.protocol.BooleanReplayConvertor; +import org.redisson.client.protocol.LongReplayConvertor; import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand.ValueType; import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.StringCodec; -import org.redisson.client.protocol.decoder.LongReplayDecoder; import org.redisson.client.protocol.decoder.MapScanResult; import org.redisson.connection.ConnectionManager; import org.redisson.core.Predicate; @@ -162,14 +162,13 @@ public class RedissonMap extends RedissonExpirable implements RMap { @Override public boolean remove(Object key, Object value) { - Long result = connectionManager.get(removeAsync(key, value)); - return result != null && result == 1; + return connectionManager.get(removeAsync(key, value)) == 1; } @Override public Future removeAsync(Object key, Object value) { - return connectionManager.evalAsync(new RedisCommand("EVAL", new LongReplayDecoder(), 4, ValueType.MAP), - "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then return redis.call('hdel', KEYS[1], ARGV[1]) else return nil end", + return connectionManager.evalAsync(new RedisCommand("EVAL", new LongReplayConvertor(), 4, ValueType.MAP), + "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then return redis.call('hdel', KEYS[1], ARGV[1]) else return 0 end", Collections.singletonList(getName()), key, value); } diff --git a/src/main/java/org/redisson/client/protocol/decoder/LongReplayDecoder.java b/src/main/java/org/redisson/client/protocol/LongReplayConvertor.java similarity index 63% rename from src/main/java/org/redisson/client/protocol/decoder/LongReplayDecoder.java rename to src/main/java/org/redisson/client/protocol/LongReplayConvertor.java index d23842def..956747bd2 100644 --- a/src/main/java/org/redisson/client/protocol/decoder/LongReplayDecoder.java +++ b/src/main/java/org/redisson/client/protocol/LongReplayConvertor.java @@ -13,21 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.redisson.client.protocol.decoder; +package org.redisson.client.protocol; -import org.redisson.client.protocol.Decoder; - -import io.netty.buffer.ByteBuf; -import io.netty.util.CharsetUtil; - -public class LongReplayDecoder implements Decoder { +public class LongReplayConvertor implements Convertor { @Override - public Long decode(ByteBuf buf) { - if (buf == null) { - return 0L; - } - return Long.valueOf(buf.toString(CharsetUtil.UTF_8)); + public Long convert(Object obj) { + return Long.valueOf(obj.toString()); } + }