DATAREDIS-334 - Add binary alternative for RedisScriptingCommands.evalSha.
Introduced new evalSha method that accepts a byte[] as scriptSha as well as a variable number of byte[] as keyValueArgs. Original pull request: #99.
This commit is contained in:
committed by
Thomas Darimont
parent
9ecad07587
commit
4711693669
@@ -1230,6 +1230,14 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
return result;
|
||||
}
|
||||
|
||||
public <T> T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||
T result = delegate.evalSha(scriptSha1, returnType, numKeys, keysAndArgs);
|
||||
if (isFutureConversion()) {
|
||||
addResultConverter(identityConverter);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// String methods
|
||||
//
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Christoph Strobl
|
||||
* @author David Liu
|
||||
*/
|
||||
public interface RedisScriptingCommands {
|
||||
|
||||
@@ -81,4 +82,17 @@ public interface RedisScriptingCommands {
|
||||
* @return
|
||||
*/
|
||||
<T> T evalSha(String scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs);
|
||||
|
||||
/**
|
||||
* Evaluate given {@code scriptSha}.
|
||||
*
|
||||
* @see http://redis.io/commands/evalsha
|
||||
* @param script
|
||||
* @param returnType
|
||||
* @param numKeys
|
||||
* @param keysAndArgs
|
||||
* @return
|
||||
* @since 1.5
|
||||
*/
|
||||
<T> T evalSha(byte[] scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs);
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ import redis.clients.util.Pool;
|
||||
* @author Thomas Darimont
|
||||
* @author Jungtaek Lim
|
||||
* @author Konstantin Shchepanovskyi
|
||||
* @author David Liu
|
||||
*/
|
||||
public class JedisConnection extends AbstractRedisConnection {
|
||||
|
||||
@@ -2799,8 +2800,13 @@ public class JedisConnection extends AbstractRedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T evalSha(String scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||
return evalSha(JedisConverters.toBytes(scriptSha1), returnType, numKeys, keysAndArgs);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||
|
||||
if (isQueueing()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -2808,8 +2814,7 @@ public class JedisConnection extends AbstractRedisConnection {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
try {
|
||||
return (T) new JedisScriptReturnConverter(returnType).convert(jedis.evalsha(JedisConverters.toBytes(scriptSha1),
|
||||
numKeys, keysAndArgs));
|
||||
return (T) new JedisScriptReturnConverter(returnType).convert(jedis.evalsha(scriptSha1, numKeys, keysAndArgs));
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Jennifer Hickey
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author David Liu
|
||||
*/
|
||||
public class JredisConnection extends AbstractRedisConnection {
|
||||
|
||||
@@ -1183,6 +1184,10 @@ public class JredisConnection extends AbstractRedisConnection {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public <T> T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisServerCommands#time()
|
||||
|
||||
@@ -99,6 +99,7 @@ import com.lambdaworks.redis.pubsub.RedisPubSubConnection;
|
||||
* @author Jennifer Hickey
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author David Liu
|
||||
*/
|
||||
public class LettuceConnection extends AbstractRedisConnection {
|
||||
|
||||
@@ -2849,6 +2850,10 @@ public class LettuceConnection extends AbstractRedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||
return evalSha(LettuceConverters.toString(scriptSha1), returnType, numKeys, keysAndArgs);
|
||||
}
|
||||
|
||||
//
|
||||
// Pub/Sub functionality
|
||||
//
|
||||
|
||||
@@ -68,6 +68,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||
* @author Jennifer Hickey
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author David Liu
|
||||
*/
|
||||
public class SrpConnection extends AbstractRedisConnection {
|
||||
|
||||
@@ -2100,6 +2101,10 @@ public class SrpConnection extends AbstractRedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T evalSha(byte[] scriptSha1, ReturnType returnType, int numKeys, byte[]... keysAndArgs) {
|
||||
return evalSha(SrpConverters.toString(scriptSha1), returnType, numKeys, keysAndArgs);
|
||||
}
|
||||
|
||||
//
|
||||
// Pub/Sub functionality
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user