Merge branch 'native_execute'

This commit is contained in:
Costin Leau
2012-06-21 19:56:41 +03:00
7 changed files with 521 additions and 413 deletions

View File

@@ -1152,4 +1152,17 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
public void openPipeline() {
delegate.openPipeline();
}
public Object execute(String command) {
return execute(command, (byte[][]) null);
}
public Object execute(String command, byte[]... args) {
return delegate.execute(command, args);
}
public Object execute(String command, String... args) {
return execute(command, serializeMulti(args));
}
}

View File

@@ -25,4 +25,16 @@ package org.springframework.data.redis.connection;
public interface RedisCommands extends RedisKeyCommands, RedisStringCommands, RedisListCommands, RedisSetCommands,
RedisZSetCommands, RedisHashCommands, RedisTxCommands, RedisPubSubCommands, RedisConnectionCommands,
RedisServerCommands {
/**
* 'Native' or 'raw' execution of the given command along-side the given arguments.
* The command is executed as is, with as little 'interpretation' as possible - it is up to the caller
* to take care of any processing of arguments or the result.
*
* @param command Command to execute
* @param args Possible command arguments (may be null)
* @return execution result.
*/
Object execute(String command, byte[]... args);
}

View File

@@ -42,6 +42,10 @@ public interface StringRedisConnection extends RedisConnection {
String getValueAsString();
}
Object execute(String command, String... args);
Object execute(String command);
Boolean exists(String key);
Long del(String... keys);

View File

@@ -16,7 +16,12 @@
package org.springframework.data.redis.connection;
import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
@@ -34,12 +39,6 @@ import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.Address;
import org.springframework.data.redis.ConnectionFactoryTracker;
import org.springframework.data.redis.Person;
import org.springframework.data.redis.connection.DefaultStringRedisConnection;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.StringRedisConnection;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
@@ -333,4 +332,12 @@ public abstract class AbstractConnectionIntegrationTests {
th.start();
connection.pSubscribe(listener, expectedPattern);
}
@Test
public void testExecuteNative() throws Exception {
connection.execute("ZADD", getClass() + "#testExecuteNative", "0.9090", "item");
//connection.execute("PiNg");
connection.execute("iNFo");
connection.execute("SET ", getClass() + "testSetNative", UUID.randomUUID().toString());
}
}