protected RFuture<Void> putAllOperationAsync(Map<? extends K, ? extends V> map) { List<Object> params = new ArrayList<Object>(map.size()*2 + 1); params.add(getName()); for (java.util.Map.Entry<? extends K, ? extends V> t : map.entrySet()) { checkKey(t.getKey()); checkValue(t.getValue()); params.add(encodeMapKey(t.getKey())); params.add(encodeMapValue(t.getValue())); } RFuture<Void> future = commandExecutor.writeAsync(getName(), codec, RedisCommands.HMSET, params.toArray()); return future; }
protected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then " + "redis.call('hset', KEYS[1], ARGV[1], ARGV[3]); " + "return 1; " + "else " + "return 0; " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(oldValue), encodeMapValue(newValue)); }
protected RFuture<Void> putAllOperationAsync(Map<? extends K, ? extends V> map) { List<Object> params = new ArrayList<Object>(map.size()*2 + 1); params.add(getName()); for (java.util.Map.Entry<? extends K, ? extends V> t : map.entrySet()) { checkKey(t.getKey()); checkValue(t.getValue()); params.add(encodeMapKey(t.getKey())); params.add(encodeMapValue(t.getValue())); } RFuture<Void> future = commandExecutor.writeAsync(getName(), codec, RedisCommands.HMSET, params.toArray()); return future; }
protected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then " + "redis.call('hset', KEYS[1], ARGV[1], ARGV[3]); " + "return 1; " + "else " + "return 0; " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(oldValue), encodeMapValue(newValue)); }
protected RFuture<Boolean> removeOperationAsync(Object key, Object value) { RFuture<Boolean> future = commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then " + "return redis.call('hdel', KEYS[1], ARGV[1]) " + "else " + "return 0 " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); return future; }
protected RFuture<Boolean> fastReplaceOperationAsync(final K key, final V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('hexists', KEYS[1], ARGV[1]) == 1 then " + "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " + "return 1; " + "else " + "return 0; " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<V> putIfAbsentOperationAsync(K key, V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "if redis.call('hsetnx', KEYS[1], ARGV[1], ARGV[2]) == 1 then " + "return nil " + "else " + "return redis.call('hget', KEYS[1], ARGV[1]) " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<Boolean> removeOperationAsync(Object key, Object value) { RFuture<Boolean> future = commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('hget', KEYS[1], ARGV[1]) == ARGV[2] then " + "return redis.call('hdel', KEYS[1], ARGV[1]) " + "else " + "return 0 " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); return future; }
protected RFuture<Boolean> fastReplaceOperationAsync(final K key, final V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('hexists', KEYS[1], ARGV[1]) == 1 then " + "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " + "return 1; " + "else " + "return 0; " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<V> putOperationAsync(K key, V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "local v = redis.call('hget', KEYS[1], ARGV[1]); " + "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " + "return v", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<V> replaceOperationAsync(final K key, final V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "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.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<V> putOperationAsync(K key, V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "local v = redis.call('hget', KEYS[1], ARGV[1]); " + "redis.call('hset', KEYS[1], ARGV[1], ARGV[2]); " + "return v", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<V> putIfAbsentOperationAsync(K key, V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "if redis.call('hsetnx', KEYS[1], ARGV[1], ARGV[2]) == 1 then " + "return nil " + "else " + "return redis.call('hget', KEYS[1], ARGV[1]) " + "end", Collections.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<V> replaceOperationAsync(final K key, final V value) { return commandExecutor.evalWriteAsync(getName(key), codec, RedisCommands.EVAL_MAP_VALUE, "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.<Object>singletonList(getName(key)), encodeMapKey(key), encodeMapValue(value)); }
@Override public RFuture<Boolean> containsValueAsync(Object value) { checkValue(value); return commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN, "local s = redis.call('hvals', KEYS[1]);" + "for i = 1, #s, 1 do " + "if ARGV[1] == s[i] then " + "return 1 " + "end " + "end;" + "return 0", Collections.<Object>singletonList(getName()), encodeMapValue(value)); }
@Override public RFuture<Boolean> containsValueAsync(Object value) { checkValue(value); return commandExecutor.evalReadAsync(getName(), codec, RedisCommands.EVAL_BOOLEAN, "local s = redis.call('hvals', KEYS[1]);" + "for i = 1, #s, 1 do " + "if ARGV[1] == s[i] then " + "return 1 " + "end " + "end;" + "return 0", Collections.<Object>singletonList(getName()), encodeMapValue(value)); }
protected RFuture<Boolean> fastPutOperationAsync(K key, V value) { return commandExecutor.writeAsync(getName(key), codec, RedisCommands.HSET, getName(key), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value) { return commandExecutor.writeAsync(getName(key), codec, RedisCommands.HSETNX, getName(key), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<Boolean> fastPutOperationAsync(K key, V value) { return commandExecutor.writeAsync(getName(key), codec, RedisCommands.HSET, getName(key), encodeMapKey(key), encodeMapValue(value)); }
protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value) { return commandExecutor.writeAsync(getName(key), codec, RedisCommands.HSETNX, getName(key), encodeMapKey(key), encodeMapValue(value)); }