RMap.putIfAbsent optimization

pull/365/head
Nikita 9 years ago
parent 43534cd4bb
commit 3b6e35f512

@ -194,8 +194,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override @Override
public Future<V> putIfAbsentAsync(K key, V value) { public Future<V> putIfAbsentAsync(K key, V value) {
return commandExecutor.evalWriteAsync(getName(), codec, EVAL_PUT, return commandExecutor.evalWriteAsync(getName(), codec, EVAL_PUT,
"if redis.call('hexists', KEYS[1], ARGV[1]) == 0 then " "if redis.call('hsetnx', KEYS[1], ARGV[1], ARGV[2]) == 1 then "
+ "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); "
+ "return nil " + "return nil "
+ "else " + "else "
+ "return redis.call('hget', KEYS[1], ARGV[1]) " + "return redis.call('hget', KEYS[1], ARGV[1]) "

Loading…
Cancel
Save