DATAREDIS-333 - Use binary version of Jedis.evalsha()

* JedisConnection.eval() uses binary version of Jedis.eval()
* but JedisConnection.evalsha() uses string version of Jedis.evalsha()
* this commit changes JedisConnection.evalsha() to use binary version of Jedis.evalsha()

---

Original Pull Request: #91
CLA: 88220140729064528 (Jungtaek Lim)
This commit is contained in:
Jungtaek Lim
2014-07-30 10:12:14 +09:00
committed by Christoph Strobl
parent 9a9443b9ff
commit e0dbbaa22b
2 changed files with 9 additions and 3 deletions

View File

@@ -31,8 +31,8 @@ import java.util.concurrent.TimeUnit;
import org.springframework.core.convert.converter.Converter;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.ExceptionTranslationStrategy;
import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.data.redis.FallbackExceptionTranslationStrategy;
import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.connection.FutureResult;
import org.springframework.data.redis.connection.MessageListener;
@@ -73,6 +73,7 @@ import redis.clients.util.Pool;
* @author Jennifer Hickey
* @author Christoph Strobl
* @author Thomas Darimont
* @author Jungtaek Lim
*/
public class JedisConnection implements RedisConnection {
@@ -2793,8 +2794,8 @@ public class JedisConnection implements RedisConnection {
throw new UnsupportedOperationException();
}
try {
return (T) new JedisScriptReturnConverter(returnType).convert(jedis.evalsha(scriptSha1, numKeys,
JedisConverters.toStrings(keysAndArgs)));
return (T) new JedisScriptReturnConverter(returnType).convert(jedis.evalsha(JedisConverters.toBytes(scriptSha1),
numKeys, keysAndArgs));
} catch (Exception ex) {
throw convertJedisAccessException(ex);
}

View File

@@ -48,6 +48,7 @@ import redis.clients.util.SafeEncoder;
*
* @author Jennifer Hickey
* @author Christoph Strobl
* @author Jungtaek Lim
*/
abstract public class JedisConverters extends Converters {
@@ -117,6 +118,10 @@ abstract public class JedisConverters extends Converters {
return String.valueOf(source).getBytes();
}
public static byte[] toBytes(String source) {
return STRING_TO_BYTES.convert(source);
}
public static String toString(byte[] source) {
return source == null ? null : SafeEncoder.encode(source);
}