diff --git a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java b/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java
index 2ea1d5556..e82608e4a 100644
--- a/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/jredis/JredisConnection.java
@@ -15,6 +15,8 @@
*/
package org.springframework.data.redis.connection.jredis;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
@@ -28,7 +30,9 @@ import org.jredis.JRedis;
import org.jredis.Query.Support;
import org.jredis.RedisException;
import org.jredis.Sort;
+import org.jredis.protocol.Command;
import org.jredis.ri.alphazero.JRedisService;
+import org.jredis.ri.alphazero.JRedisSupport;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.RedisSystemException;
import org.springframework.data.redis.connection.DataType;
@@ -37,6 +41,7 @@ import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.SortParameters;
import org.springframework.data.redis.connection.Subscription;
import org.springframework.util.Assert;
+import org.springframework.util.ReflectionUtils;
/**
* {@code RedisConnection} implementation on top of JRedis library.
@@ -45,10 +50,18 @@ import org.springframework.util.Assert;
*/
public class JredisConnection implements RedisConnection {
+ private static final Method SERVICE_REQUEST;
+
private final JRedis jredis;
private final boolean isPool;
private boolean isClosed = false;
+ static {
+ SERVICE_REQUEST = ReflectionUtils.findMethod(JRedisSupport.class, "serviceRequest", Command.class,
+ byte[][].class);
+ ReflectionUtils.makeAccessible(SERVICE_REQUEST);
+ }
+
/**
* Constructs a new JredisConnection instance.
*
@@ -73,7 +86,18 @@ public class JredisConnection implements RedisConnection {
return new RedisSystemException("Unknown JRedis exception", ex);
}
-
+ public Object execute(String command, byte[]... args) {
+ Assert.hasText(command, "a valid command needs to be specified");
+ List mArgs = new ArrayList();
+ if (args != null) {
+ Collections.addAll(mArgs, args);
+ }
+
+ return ReflectionUtils.invokeMethod(SERVICE_REQUEST, jredis, Command.valueOf(command.trim().toUpperCase()),
+ mArgs.toArray(new byte[mArgs.size()][]));
+
+ }
+
public void close() throws RedisSystemException {
isClosed = true;
@@ -88,37 +112,37 @@ public class JredisConnection implements RedisConnection {
}
}
-
+
public JRedis getNativeConnection() {
return jredis;
}
-
+
public boolean isClosed() {
return isClosed;
}
-
+
public boolean isQueueing() {
return false;
}
-
+
public boolean isPipelined() {
return false;
}
-
+
public void openPipeline() {
throw new UnsupportedOperationException("Pipelining not supported by JRedis");
}
-
+
public List