From 9e00be8c3c6bdb83c7e776ffb515baa51c7d4489 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 23 Nov 2015 15:27:37 +0300 Subject: [PATCH] code formatted --- src/main/java/org/redisson/RedissonMap.java | 37 +++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/redisson/RedissonMap.java b/src/main/java/org/redisson/RedissonMap.java index c32e11bfb..fe5902f96 100644 --- a/src/main/java/org/redisson/RedissonMap.java +++ b/src/main/java/org/redisson/RedissonMap.java @@ -50,7 +50,6 @@ import io.netty.util.concurrent.Future; * @param key * @param value */ -//TODO implement watching by keys instead of map name public class RedissonMap extends RedissonExpirable implements RMap { private static final RedisCommand EVAL_REMOVE = new RedisCommand("EVAL", 4, ValueType.MAP_KEY, ValueType.MAP_VALUE); @@ -205,7 +204,12 @@ public class RedissonMap extends RedissonExpirable implements RMap { @Override public Future putIfAbsentAsync(K key, V value) { return commandExecutor.evalWriteAsync(getName(), codec, EVAL_PUT, - "if redis.call('hexists', KEYS[1], ARGV[1]) == 0 then redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); return nil else return redis.call('hget', KEYS[1], ARGV[1]) end", + "if redis.call('hexists', KEYS[1], ARGV[1]) == 0 then " + + "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " + + "return nil " + + "else " + + "return redis.call('hget', KEYS[1], ARGV[1]) " + + "end", Collections.singletonList(getName()), key, value); } @@ -217,7 +221,11 @@ public class RedissonMap extends RedissonExpirable implements RMap { @Override public Future removeAsync(Object key, Object value) { return commandExecutor.evalWriteAsync(getName(), codec, EVAL_REMOVE_VALUE, - "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then return redis.call('hdel', KEYS[1], ARGV[1]) else return 0 end", + "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); } @@ -229,7 +237,12 @@ public class RedissonMap extends RedissonExpirable implements RMap { @Override public Future replaceAsync(K key, V oldValue, V newValue) { return commandExecutor.evalWriteAsync(getName(), codec, EVAL_REPLACE_VALUE, - "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then redis.call('hset', KEYS[1], ARGV[1], ARGV[3]); return true; else return false; end", + "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then " + + "redis.call('hset', KEYS[1], ARGV[1], ARGV[3]); " + + "return true; " + + "else " + + "return false; " + + "end", Collections.singletonList(getName()), key, oldValue, newValue); } @@ -241,7 +254,13 @@ public class RedissonMap extends RedissonExpirable implements RMap { @Override public Future replaceAsync(K key, V value) { return commandExecutor.evalWriteAsync(getName(), codec, EVAL_REPLACE, - "if redis.call('hexists', KEYS[1], ARGV[1]) == 1 then local v = redis.call('hget', KEYS[1], ARGV[1]); redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); return v; else return nil; end", + "if redis.call('hexists', KEYS[1], ARGV[1]) == 1 then " + + "local v = redis.call('hget', KEYS[1], ARGV[1]); " + + "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " + + "return v; " + + "else " + + "return nil; " + + "end", Collections.singletonList(getName()), key, value); } @@ -253,7 +272,9 @@ public class RedissonMap extends RedissonExpirable implements RMap { @Override public Future putAsync(K key, V value) { return commandExecutor.evalWriteAsync(getName(), codec, EVAL_PUT, - "local v = redis.call('hget', KEYS[1], ARGV[1]); redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); return v", + "local v = redis.call('hget', KEYS[1], ARGV[1]); " + + "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " + + "return v", Collections.singletonList(getName()), key, value); } @@ -261,7 +282,9 @@ public class RedissonMap extends RedissonExpirable implements RMap { @Override public Future removeAsync(K key) { return commandExecutor.evalWriteAsync(getName(), codec, EVAL_REMOVE, - "local v = redis.call('hget', KEYS[1], ARGV[1]); redis.call('hdel', KEYS[1], ARGV[1]); return v", + "local v = redis.call('hget', KEYS[1], ARGV[1]); " + + "redis.call('hdel', KEYS[1], ARGV[1]); " + + "return v", Collections.singletonList(getName()), key); }