Merge branch 'master' into 3.0.0

pull/1821/head
Nikita Koksharov 6 years ago
commit 5ed126629c

@ -148,6 +148,8 @@ RExecutorService executor = redisson.getExecutorService("myExecutorService");
``` ```
Please consider __[Redisson PRO](https://redisson.pro)__ version for advanced features and support by SLA.
Downloads Downloads
=============================== ===============================

@ -416,6 +416,11 @@ public class Redisson implements RedissonClient {
public RScript getScript() { public RScript getScript() {
return new RedissonScript(connectionManager.getCommandExecutor()); return new RedissonScript(connectionManager.getCommandExecutor());
} }
@Override
public RScript getScript(Codec codec) {
return new RedissonScript(connectionManager.getCommandExecutor(), codec);
}
@Override @Override
public RScheduledExecutorService getExecutorService(String name) { public RScheduledExecutorService getExecutorService(String name) {

@ -39,6 +39,7 @@ import org.redisson.api.RMultimapAsync;
import org.redisson.api.RMultimapCacheAsync; import org.redisson.api.RMultimapCacheAsync;
import org.redisson.api.RQueueAsync; import org.redisson.api.RQueueAsync;
import org.redisson.api.RScoredSortedSetAsync; import org.redisson.api.RScoredSortedSetAsync;
import org.redisson.api.RScript;
import org.redisson.api.RScriptAsync; import org.redisson.api.RScriptAsync;
import org.redisson.api.RSetAsync; import org.redisson.api.RSetAsync;
import org.redisson.api.RSetCacheAsync; import org.redisson.api.RSetCacheAsync;
@ -211,6 +212,11 @@ public class RedissonBatch implements RBatch {
public RScriptAsync getScript() { public RScriptAsync getScript() {
return new RedissonScript(executorService); return new RedissonScript(executorService);
} }
@Override
public RScript getScript(Codec codec) {
return new RedissonScript(executorService, codec);
}
@Override @Override
public RKeysAsync getKeys() { public RKeysAsync getKeys() {

@ -382,6 +382,11 @@ public class RedissonReactive implements RedissonReactiveClient {
public RScriptReactive getScript() { public RScriptReactive getScript() {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor), RScriptReactive.class); return ReactiveProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor), RScriptReactive.class);
} }
@Override
public RScriptReactive getScript(Codec codec) {
return ReactiveProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor, codec), RScriptReactive.class);
}
@Override @Override
public RBatchReactive createBatch(BatchOptions options) { public RBatchReactive createBatch(BatchOptions options) {

@ -373,6 +373,11 @@ public class RedissonRx implements RedissonRxClient {
public RScriptRx getScript() { public RScriptRx getScript() {
return RxProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor), RScriptRx.class); return RxProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor), RScriptRx.class);
} }
@Override
public RScriptRx getScript(Codec codec) {
return RxProxyBuilder.create(commandExecutor, new RedissonScript(commandExecutor, codec), RScriptRx.class);
}
@Override @Override
public RBatchRx createBatch(BatchOptions options) { public RBatchRx createBatch(BatchOptions options) {

@ -39,10 +39,17 @@ import io.netty.buffer.ByteBuf;
*/ */
public class RedissonScript implements RScript { public class RedissonScript implements RScript {
private final Codec codec;
private final CommandAsyncExecutor commandExecutor; private final CommandAsyncExecutor commandExecutor;
public RedissonScript(CommandAsyncExecutor commandExecutor) { public RedissonScript(CommandAsyncExecutor commandExecutor) {
this.commandExecutor = commandExecutor; this.commandExecutor = commandExecutor;
this.codec = commandExecutor.getConnectionManager().getCodec();
}
public RedissonScript(CommandAsyncExecutor commandExecutor, Codec codec) {
this.commandExecutor = commandExecutor;
this.codec = codec;
} }
@Override @Override
@ -70,88 +77,68 @@ public class RedissonScript implements RScript {
}, luaScript); }, luaScript);
} }
@Override
public RFuture<String> scriptLoadAsync(String key, String luaScript) { public RFuture<String> scriptLoadAsync(String key, String luaScript) {
return commandExecutor.writeAsync(key, RedisCommands.SCRIPT_LOAD, luaScript); return commandExecutor.writeAsync(key, RedisCommands.SCRIPT_LOAD, luaScript);
} }
@Override @Override
public <R> R eval(Mode mode, String luaScript, ReturnType returnType) { public <R> R eval(Mode mode, String luaScript, ReturnType returnType) {
return eval(null, mode, commandExecutor.getConnectionManager().getCodec(), luaScript, returnType); return eval(mode, luaScript, returnType, Collections.emptyList());
} }
@Override @Override
public <R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType) { public <R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType) {
return eval(null, mode, codec, luaScript, returnType); RedissonScript script = new RedissonScript(commandExecutor, codec);
} return script.eval(mode, luaScript, returnType);
public <R> R eval(String key, Mode mode, Codec codec, String luaScript, ReturnType returnType) {
return eval(key, mode, codec, luaScript, returnType, Collections.emptyList());
} }
@Override @Override
public <R> R eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values) { public <R> R eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values) {
return eval(null, mode, commandExecutor.getConnectionManager().getCodec(), luaScript, returnType, keys, values); return eval(null, mode, luaScript, returnType, keys, values);
} }
@Override @Override
public <R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values) { public <R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values) {
return eval(null, mode, codec, luaScript, returnType, keys, values); RedissonScript script = new RedissonScript(commandExecutor, codec);
} return script.eval(mode, luaScript, returnType, keys, values);
public <R> R eval(String key, Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values) {
return (R) commandExecutor.get(evalAsync(key, mode, codec, luaScript, returnType, keys, values));
} }
@Override @Override
public <R> RFuture<R> evalAsync(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values) { public <R> RFuture<R> evalAsync(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values) {
return evalAsync(null, mode, commandExecutor.getConnectionManager().getCodec(), luaScript, returnType, keys, values); return evalAsync(null, mode, luaScript, returnType, keys, values);
} }
@Override @Override
public <R> RFuture<R> evalAsync(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values) { public <R> RFuture<R> evalAsync(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values) {
return evalAsync(null, mode, codec, luaScript, returnType, keys, values); RedissonScript script = new RedissonScript(commandExecutor, codec);
return script.evalAsync(mode, luaScript, returnType, keys, values);
} }
@Override @Override
public <R> RFuture<R> evalAsync(String key, Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values) { public <R> RFuture<R> evalAsync(String key, Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values) {
if (mode == Mode.READ_ONLY) { RedissonScript script = new RedissonScript(commandExecutor, codec);
return commandExecutor.evalReadAsync(key, codec, returnType.getCommand(), luaScript, keys, encode(Arrays.asList(values), codec).toArray()); return script.evalAsync(key, mode, luaScript, returnType, keys, values);
}
return commandExecutor.evalWriteAsync(key, codec, returnType.getCommand(), luaScript, keys, encode(Arrays.asList(values), codec).toArray());
} }
@Override @Override
public <R> R evalSha(Mode mode, String shaDigest, ReturnType returnType) { public <R> R evalSha(Mode mode, String shaDigest, ReturnType returnType) {
return evalSha(null, mode, commandExecutor.getConnectionManager().getCodec(), shaDigest, returnType); return evalSha(null, mode, shaDigest, returnType, Collections.emptyList());
} }
@Override @Override
public <R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType) { public <R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType) {
return evalSha(null, mode, codec, shaDigest, returnType); return evalSha(mode, codec, shaDigest, returnType, Collections.emptyList());
}
public <R> R evalSha(String key, Mode mode, String shaDigest, ReturnType returnType) {
return evalSha(key, mode, commandExecutor.getConnectionManager().getCodec(), shaDigest, returnType, Collections.emptyList());
} }
public <R> R evalSha(String key, Mode mode, Codec codec, String shaDigest, ReturnType returnType) {
return evalSha(key, mode, codec, shaDigest, returnType, Collections.emptyList());
}
@Override @Override
public <R> R evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values) { public <R> R evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values) {
return evalSha(null, mode, commandExecutor.getConnectionManager().getCodec(), shaDigest, returnType, keys, values); return evalSha(null, mode, shaDigest, returnType, keys, values);
} }
@Override @Override
public <R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values) { public <R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values) {
return evalSha(null, mode, codec, shaDigest, returnType, keys, values); return (R) commandExecutor.get(evalShaAsync(null, mode, codec, shaDigest, returnType, keys, values));
}
public <R> R evalSha(String key, Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values) {
return (R) commandExecutor.get(evalShaAsync(key, mode, codec, shaDigest, returnType, keys, values));
} }
@Override @Override
@ -165,11 +152,8 @@ public class RedissonScript implements RScript {
} }
public <R> RFuture<R> evalShaAsync(String key, Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values) { public <R> RFuture<R> evalShaAsync(String key, Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values) {
RedisCommand command = new RedisCommand(returnType.getCommand(), "EVALSHA"); RedissonScript script = new RedissonScript(commandExecutor, codec);
if (mode == Mode.READ_ONLY) { return script.evalShaAsync(key, mode, shaDigest, returnType, keys, values);
return commandExecutor.evalReadAsync(key, codec, command, shaDigest, keys, encode(Arrays.asList(values), codec).toArray());
}
return commandExecutor.evalWriteAsync(key, codec, command, shaDigest, keys, encode(Arrays.asList(values), codec).toArray());
} }
@Override @Override
@ -238,7 +222,6 @@ public class RedissonScript implements RScript {
return commandExecutor.writeAllAsync(RedisCommands.SCRIPT_FLUSH); return commandExecutor.writeAllAsync(RedisCommands.SCRIPT_FLUSH);
} }
// @Override
public RFuture<Void> scriptFlushAsync(String key) { public RFuture<Void> scriptFlushAsync(String key) {
return commandExecutor.writeAsync(key, RedisCommands.SCRIPT_FLUSH); return commandExecutor.writeAsync(key, RedisCommands.SCRIPT_FLUSH);
} }
@ -286,4 +269,35 @@ public class RedissonScript implements RScript {
} }
} }
@Override
public <R> RFuture<R> evalShaAsync(String key, Mode mode, String shaDigest, ReturnType returnType,
List<Object> keys, Object... values) {
RedisCommand command = new RedisCommand(returnType.getCommand(), "EVALSHA");
if (mode == Mode.READ_ONLY) {
return commandExecutor.evalReadAsync(key, codec, command, shaDigest, keys, encode(Arrays.asList(values), codec).toArray());
}
return commandExecutor.evalWriteAsync(key, codec, command, shaDigest, keys, encode(Arrays.asList(values), codec).toArray());
}
@Override
public <R> RFuture<R> evalAsync(String key, Mode mode, String luaScript, ReturnType returnType, List<Object> keys,
Object... values) {
if (mode == Mode.READ_ONLY) {
return commandExecutor.evalReadAsync(key, codec, returnType.getCommand(), luaScript, keys, encode(Arrays.asList(values), codec).toArray());
}
return commandExecutor.evalWriteAsync(key, codec, returnType.getCommand(), luaScript, keys, encode(Arrays.asList(values), codec).toArray());
}
@Override
public <R> R evalSha(String key, Mode mode, String shaDigest, ReturnType returnType, List<Object> keys,
Object... values) {
return commandExecutor.get((RFuture<R>)evalShaAsync(key, mode, shaDigest, returnType, keys, values));
}
@Override
public <R> R eval(String key, Mode mode, String luaScript, ReturnType returnType, List<Object> keys,
Object... values) {
return commandExecutor.get((RFuture<R>)evalAsync(key, mode, luaScript, returnType, keys, values));
}
} }

@ -393,6 +393,14 @@ public interface RBatch {
*/ */
RScriptAsync getScript(); RScriptAsync getScript();
/**
* Returns script operations object using provided codec.
*
* @param codec - codec for params and result
* @return Script object
*/
RScript getScript(Codec codec);
/** /**
* Returns keys operations. * Returns keys operations.
* Each of Redis/Redisson object associated with own key * Each of Redis/Redisson object associated with own key

@ -341,6 +341,14 @@ public interface RBatchReactive {
*/ */
RScriptReactive getScript(); RScriptReactive getScript();
/**
* Returns script operations object using provided codec.
*
* @param codec - codec for params and result
* @return Script object
*/
RScriptReactive getScript(Codec codec);
/** /**
* Returns keys operations. * Returns keys operations.
* Each of Redis/Redisson object associated with own key * Each of Redis/Redisson object associated with own key

@ -342,6 +342,14 @@ public interface RBatchRx {
*/ */
RScriptRx getScript(); RScriptRx getScript();
/**
* Returns script operations object using provided codec.
*
* @param codec - codec for params and result
* @return Script object
*/
RScriptRx getScript(Codec codec);
/** /**
* Returns keys operations. * Returns keys operations.
* Each of Redis/Redisson object associated with own key * Each of Redis/Redisson object associated with own key

@ -22,6 +22,7 @@ import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisCommands;
/** /**
* Interface for Redis Script feature
* *
* @author Nikita Koksharov * @author Nikita Koksharov
* *
@ -51,28 +52,132 @@ public interface RScript extends RScriptAsync {
}; };
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> R evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); <R> R evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> R evalSha(String key, Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); <R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @return result object
*/
<R> R evalSha(Mode mode, String shaDigest, ReturnType returnType); <R> R evalSha(Mode mode, String shaDigest, ReturnType returnType);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType); <R> R evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType);
/**
* Executes Lua script
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> R eval(String key, Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> R eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values); <R> R eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values); <R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @return result object
*/
<R> R eval(Mode mode, String luaScript, ReturnType returnType); <R> R eval(Mode mode, String luaScript, ReturnType returnType);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType); <R> R eval(Mode mode, Codec codec, String luaScript, ReturnType returnType);
/**
* Loads Lua script into Redis scripts cache and returns its SHA-1 digest
*
* @param luaScript - lua script
* @return SHA-1 digest
*/
String scriptLoad(String luaScript); String scriptLoad(String luaScript);
/**
* Checks for presence Lua scripts in Redis script cache by SHA-1 digest.
*
* @param shaDigests - collection of SHA-1 digests
* @return list of booleans corresponding to collection SHA-1 digests
*/
List<Boolean> scriptExists(String ... shaDigests); List<Boolean> scriptExists(String ... shaDigests);
/**
* Kills currently executed Lua script
*
*/
void scriptKill(); void scriptKill();
/**
* Flushes Lua script cache.
*
*/
void scriptFlush(); void scriptFlush();
} }

@ -22,42 +22,171 @@ import org.redisson.api.RScript.ReturnType;
import org.redisson.client.codec.Codec; import org.redisson.client.codec.Codec;
/** /**
* Async interface for Redis Script feature
* *
* @author Nikita Koksharov * @author Nikita Koksharov
* *
*/ */
public interface RScriptAsync { public interface RScriptAsync {
/**
* Flushes Lua script cache.
*
* @return void
*/
RFuture<Void> scriptFlushAsync(); RFuture<Void> scriptFlushAsync();
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> RFuture<R> evalShaAsync(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); <R> RFuture<R> evalShaAsync(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> RFuture<R> evalShaAsync(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); <R> RFuture<R> evalShaAsync(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
<R> RFuture<R> evalShaAsync(String key, Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); /**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> RFuture<R> evalShaAsync(String key, Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
<R> RFuture<R> evalShaAsync(Mode mode, String shaDigest, ReturnType returnType); /*
* Use getScript(Codec) instead
*/
@Deprecated
<R> RFuture<R> evalShaAsync(String key, Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @return result object
*/
<R> RFuture<R> evalShaAsync(Mode mode, String shaDigest, ReturnType returnType);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> RFuture<R> evalShaAsync(Mode mode, Codec codec, String shaDigest, ReturnType returnType); <R> RFuture<R> evalShaAsync(Mode mode, Codec codec, String shaDigest, ReturnType returnType);
/**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> RFuture<R> evalAsync(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values); <R> RFuture<R> evalAsync(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
<R> RFuture<R> evalAsync(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> RFuture<R> evalAsync(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> RFuture<R> evalAsync(String key, Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values); <R> RFuture<R> evalAsync(String key, Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> RFuture<R> evalAsync(String key, Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @return result object
*/
<R> RFuture<R> evalAsync(Mode mode, String luaScript, ReturnType returnType); <R> RFuture<R> evalAsync(Mode mode, String luaScript, ReturnType returnType);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> RFuture<R> evalAsync(Mode mode, Codec codec, String luaScript, ReturnType returnType); <R> RFuture<R> evalAsync(Mode mode, Codec codec, String luaScript, ReturnType returnType);
/**
* Loads Lua script into Redis scripts cache and returns its SHA-1 digest
*
* @param luaScript - lua script
* @return SHA-1 digest
*/
RFuture<String> scriptLoadAsync(String luaScript); RFuture<String> scriptLoadAsync(String luaScript);
/**
* Loads Lua script into Redis scripts cache and returns its SHA-1 digest
*
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param luaScript - lua script
* @return SHA-1 digest
*/
RFuture<String> scriptLoadAsync(String key, String luaScript); RFuture<String> scriptLoadAsync(String key, String luaScript);
/**
* Checks for presence Lua scripts in Redis script cache by SHA-1 digest.
*
* @param shaDigests - collection of SHA-1 digests
* @return list of booleans corresponding to collection SHA-1 digests
*/
RFuture<List<Boolean>> scriptExistsAsync(String ... shaDigests); RFuture<List<Boolean>> scriptExistsAsync(String ... shaDigests);
/**
* Checks for presence Lua scripts in Redis script cache by SHA-1 digest.
*
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param shaDigests - collection of SHA-1 digests
* @return list of booleans corresponding to collection SHA-1 digests
*/
RFuture<List<Boolean>> scriptExistsAsync(String key, String ... shaDigests); RFuture<List<Boolean>> scriptExistsAsync(String key, String ... shaDigests);
/**
* Kills currently executed Lua script
*
* @return void
*/
RFuture<Void> scriptKillAsync(); RFuture<Void> scriptKillAsync();
} }

@ -30,28 +30,134 @@ import org.redisson.client.codec.Codec;
*/ */
public interface RScriptReactive { public interface RScriptReactive {
/**
* Flushes Lua script cache.
*
* @return void
*/
Publisher<Void> scriptFlush(); Publisher<Void> scriptFlush();
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Publisher<R> evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); <R> Publisher<R> evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
<R> Publisher<R> evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); /**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Publisher<R> evalSha(String key, Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @return result object
*/
<R> Publisher<R> evalSha(Mode mode, String shaDigest, ReturnType returnType); <R> Publisher<R> evalSha(Mode mode, String shaDigest, ReturnType returnType);
<R> Publisher<R> evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType); /**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Publisher<R> eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values); <R> Publisher<R> eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
<R> Publisher<R> eval(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values); /**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @return result object
*/
<R> Publisher<R> eval(Mode mode, String luaScript, ReturnType returnType); <R> Publisher<R> eval(Mode mode, String luaScript, ReturnType returnType);
<R> Publisher<R> eval(Mode mode, Codec codec, String luaScript, ReturnType returnType); /**
* Executes Lua script
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Publisher<R> eval(String key, Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/**
* Loads Lua script into Redis scripts cache and returns its SHA-1 digest
*
* @param luaScript - lua script
* @return SHA-1 digest
*/
Publisher<String> scriptLoad(String luaScript); Publisher<String> scriptLoad(String luaScript);
/**
* Checks for presence Lua scripts in Redis script cache by SHA-1 digest.
*
* @param shaDigests - collection of SHA-1 digests
* @return list of booleans corresponding to collection SHA-1 digests
*/
Publisher<List<Boolean>> scriptExists(String ... shaDigests); Publisher<List<Boolean>> scriptExists(String ... shaDigests);
/**
* Kills currently executed Lua script
*
* @return void
*/
Publisher<Void> scriptKill(); Publisher<Void> scriptKill();
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> Publisher<R> evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> Publisher<R> evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> Publisher<R> eval(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/*
* Use getScript(Codec) instead
*/
@Deprecated
<R> Publisher<R> eval(Mode mode, Codec codec, String luaScript, ReturnType returnType);
} }

@ -19,7 +19,6 @@ import java.util.List;
import org.redisson.api.RScript.Mode; import org.redisson.api.RScript.Mode;
import org.redisson.api.RScript.ReturnType; import org.redisson.api.RScript.ReturnType;
import org.redisson.client.codec.Codec;
import io.reactivex.Flowable; import io.reactivex.Flowable;
@ -31,28 +30,110 @@ import io.reactivex.Flowable;
*/ */
public interface RScriptRx { public interface RScriptRx {
/**
* Flushes Lua script cache.
*
* @return void
*/
Flowable<Void> scriptFlush(); Flowable<Void> scriptFlush();
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Flowable<R> evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); <R> Flowable<R> evalSha(Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
<R> Flowable<R> evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType, List<Object> keys, Object... values); /**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Flowable<R> evalSha(String key, Mode mode, String shaDigest, ReturnType returnType, List<Object> keys, Object... values);
/**
* Executes Lua script stored in Redis scripts cache by SHA-1 digest
*
* @param <R> - type of result
* @param mode - execution mode
* @param shaDigest - SHA-1 digest
* @param returnType - return type
* @return result object
*/
<R> Flowable<R> evalSha(Mode mode, String shaDigest, ReturnType returnType); <R> Flowable<R> evalSha(Mode mode, String shaDigest, ReturnType returnType);
<R> Flowable<R> evalSha(Mode mode, Codec codec, String shaDigest, ReturnType returnType); /**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Flowable<R> eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values); <R> Flowable<R> eval(Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
<R> Flowable<R> eval(Mode mode, Codec codec, String luaScript, ReturnType returnType, List<Object> keys, Object... values); /**
* Executes Lua script
*
* @param <R> - type of result
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @return result object
*/
<R> Flowable<R> eval(Mode mode, String luaScript, ReturnType returnType); <R> Flowable<R> eval(Mode mode, String luaScript, ReturnType returnType);
<R> Flowable<R> eval(Mode mode, Codec codec, String luaScript, ReturnType returnType); /**
* Executes Lua script
*
* @param <R> - type of result
* @param key - used to locate Redis node in Cluster which stores cached Lua script
* @param mode - execution mode
* @param luaScript - lua script
* @param returnType - return type
* @param keys - keys available through KEYS param in script
* @param values - values available through VALUES param in script
* @return result object
*/
<R> Flowable<R> eval(String key, Mode mode, String luaScript, ReturnType returnType, List<Object> keys, Object... values);
/**
* Loads Lua script into Redis scripts cache and returns its SHA-1 digest
*
* @param luaScript - lua script
* @return SHA-1 digest
*/
Flowable<String> scriptLoad(String luaScript); Flowable<String> scriptLoad(String luaScript);
/**
* Checks for presence Lua scripts in Redis script cache by SHA-1 digest.
*
* @param shaDigests - collection of SHA-1 digests
* @return list of booleans corresponding to collection SHA-1 digests
*/
Flowable<List<Boolean>> scriptExists(String ... shaDigests); Flowable<List<Boolean>> scriptExists(String ... shaDigests);
/**
* Kills currently executed Lua script
*
* @return void
*/
Flowable<Void> scriptKill(); Flowable<Void> scriptKill();
} }

@ -862,6 +862,14 @@ public interface RedissonClient {
* @return Script object * @return Script object
*/ */
RScript getScript(); RScript getScript();
/**
* Returns script operations object using provided codec.
*
* @param codec - codec for params and result
* @return Script object
*/
RScript getScript(Codec codec);
/** /**
* Returns ScheduledExecutorService by name * Returns ScheduledExecutorService by name

@ -581,6 +581,14 @@ public interface RedissonReactiveClient {
*/ */
RScriptReactive getScript(); RScriptReactive getScript();
/**
* Returns script operations object using provided codec.
*
* @param codec - codec for params and result
* @return Script object
*/
RScriptReactive getScript(Codec codec);
/** /**
* Creates transaction with <b>READ_COMMITTED</b> isolation level. * Creates transaction with <b>READ_COMMITTED</b> isolation level.
* *

@ -569,6 +569,14 @@ public interface RedissonRxClient {
*/ */
RScriptRx getScript(); RScriptRx getScript();
/**
* Returns script operations object using provided codec.
*
* @param codec - codec for params and result
* @return Script object
*/
RScriptRx getScript(Codec codec);
/** /**
* Creates transaction with <b>READ_COMMITTED</b> isolation level. * Creates transaction with <b>READ_COMMITTED</b> isolation level.
* *

@ -682,14 +682,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
} }
protected void stopThreads() { protected void stopThreads() {
timer.stop(); shutdown();
executor.shutdown();
try {
executor.awaitTermination(15, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
group.shutdownGracefully().syncUninterruptibly();
} }
public PublishSubscribeService getSubscribeService() { public PublishSubscribeService getSubscribeService() {

@ -35,7 +35,7 @@ import io.netty.util.concurrent.EventExecutor;
*/ */
public class MultiDnsAddressResolverGroup extends DnsAddressResolverGroup { public class MultiDnsAddressResolverGroup extends DnsAddressResolverGroup {
List<DnsAddressResolverGroup> groups = new ArrayList<DnsAddressResolverGroup>(); private final List<DnsAddressResolverGroup> groups = new ArrayList<DnsAddressResolverGroup>();
public MultiDnsAddressResolverGroup( public MultiDnsAddressResolverGroup(
Class<? extends DatagramChannel> channelType, Class<? extends DatagramChannel> channelType,
@ -53,6 +53,9 @@ public class MultiDnsAddressResolverGroup extends DnsAddressResolverGroup {
break; break;
} }
} }
// workaround for short DNS names
groups.add(new DnsAddressResolverGroup(channelType, nameServerProvider));
} }
@Override @Override

@ -273,6 +273,11 @@ public class RedissonBatchReactive implements RBatchReactive {
public RScriptReactive getScript() { public RScriptReactive getScript() {
return ReactiveProxyBuilder.create(executorService, new RedissonScript(executorService), RScriptReactive.class); return ReactiveProxyBuilder.create(executorService, new RedissonScript(executorService), RScriptReactive.class);
} }
@Override
public RScriptReactive getScript(Codec codec) {
return ReactiveProxyBuilder.create(executorService, new RedissonScript(executorService, codec), RScriptReactive.class);
}
@Override @Override
public RKeysReactive getKeys() { public RKeysReactive getKeys() {

@ -282,6 +282,11 @@ public class RedissonBatchRx implements RBatchRx {
public RScriptRx getScript() { public RScriptRx getScript() {
return RxProxyBuilder.create(executorService, new RedissonScript(executorService), RScriptRx.class); return RxProxyBuilder.create(executorService, new RedissonScript(executorService), RScriptRx.class);
} }
@Override
public RScriptRx getScript(Codec codec) {
return RxProxyBuilder.create(executorService, new RedissonScript(executorService, codec), RScriptRx.class);
}
@Override @Override
public RKeysRx getKeys() { public RKeysRx getKeys() {

Loading…
Cancel
Save