+ remove pipeline support for now since none of the drivers support it properly

This commit is contained in:
Costin Leau
2011-04-05 20:33:18 +03:00
parent 6e76662f90
commit 9d69195799
7 changed files with 52 additions and 54 deletions

View File

@@ -1123,7 +1123,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
}
@Override
public List<byte[]> closePipeline() {
public List<Object> closePipeline() {
return delegate.closePipeline();
}

View File

@@ -95,5 +95,5 @@ public interface RedisConnection extends RedisCommands {
*
* @return the result of the executed commands.
*/
List<byte[]> closePipeline();
List<Object> closePipeline();
}

View File

@@ -187,11 +187,11 @@ public class JedisConnection implements RedisConnection {
@SuppressWarnings("unchecked")
@Override
public List<byte[]> closePipeline() {
public List<Object> closePipeline() {
if (pipeline != null) {
List execute = pipeline.execute();
if (execute != null && !execute.isEmpty()) {
return (List<byte[]>) execute;
return execute;
}
}
return Collections.emptyList();

View File

@@ -115,7 +115,7 @@ public class JredisConnection implements RedisConnection {
}
@Override
public List<byte[]> closePipeline() {
public List<Object> closePipeline() {
return Collections.emptyList();
}

View File

@@ -118,11 +118,11 @@ public class RjcConnection implements RedisConnection {
@SuppressWarnings("unchecked")
@Override
public List<byte[]> closePipeline() {
public List<Object> closePipeline() {
if (pipeline != null) {
List execute = client.getAll();
if (execute != null && !execute.isEmpty()) {
return (List<byte[]>) execute;
return execute;
}
}
return Collections.emptyList();

View File

@@ -64,15 +64,15 @@ public interface RedisOperations<K, V> {
*/
<T> T execute(SessionCallback<T> session);
/**
* Executes the given action object on a pipelined connection, returning the results. Note that the callback <b>cannot</b>
* return a non-null value as it gets overwritten by the pipeline.
*
* @param <T> list element return type
* @param action callback object to execute
* @return list of objects returned by the pipeline
*/
List<V> executePipelined(RedisCallback<?> action);
// /**
// * Executes the given action object on a pipelined connection, returning the results. Note that the callback <b>cannot</b>
// * return a non-null value as it gets overwritten by the pipeline.
// *
// * @param <T> list element return type
// * @param action callback object to execute
// * @return list of objects returned by the pipeline
// */
// List<V> executePipelined(RedisCallback<?> action);
Boolean hasKey(K key);

View File

@@ -25,7 +25,6 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.keyvalue.redis.connection.DataType;
import org.springframework.data.keyvalue.redis.connection.RedisConnection;
import org.springframework.data.keyvalue.redis.connection.RedisConnectionFactory;
@@ -205,43 +204,42 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
}
}
@Override
@SuppressWarnings("unchecked")
public List<V> executePipelined(final RedisCallback<?> action) {
return executePipelined(action, valueSerializer);
}
/**
* Executes the given action object on a pipelined connection, returning the results using a dedicated serializer.
* Note that the callback <b>cannot</b> return a non-null value as it gets overwritten by the pipeline.
*
* @param action callback object to execute
* @param resultSerializer
* @return list of objects returned by the pipeline
*/
public <T> List<T> executePipelined(final RedisCallback<?> action, final RedisSerializer<T> resultSerializer) {
return execute(new RedisCallback<List<T>>() {
public List<T> doInRedis(RedisConnection connection) throws DataAccessException {
connection.openPipeline();
boolean pipelinedClosed = false;
try {
Object result = action.doInRedis(connection);
if (result != null) {
throw new InvalidDataAccessApiUsageException(
"Callback cannot returned a non-null value as it gets overwritten by the pipeline");
}
List<byte[]> pipeline = connection.closePipeline();
pipelinedClosed = true;
return SerializationUtils.deserialize(pipeline, resultSerializer);
} finally {
if (!pipelinedClosed) {
connection.closePipeline();
}
}
}
});
}
// @SuppressWarnings("unchecked")
// public List<V> executePipelined(final RedisCallback<?> action) {
// return executePipelined(action, valueSerializer);
// }
//
// /**
// * Executes the given action object on a pipelined connection, returning the results using a dedicated serializer.
// * Note that the callback <b>cannot</b> return a non-null value as it gets overwritten by the pipeline.
// *
// * @param action callback object to execute
// * @param resultSerializer
// * @return list of objects returned by the pipeline
// */
// public <T> List<T> executePipelined(final RedisCallback<?> action, final RedisSerializer<T> resultSerializer) {
// return execute(new RedisCallback<List<T>>() {
// public List<T> doInRedis(RedisConnection connection) throws DataAccessException {
// connection.openPipeline();
// boolean pipelinedClosed = false;
// try {
// Object result = action.doInRedis(connection);
// if (result != null) {
// throw new InvalidDataAccessApiUsageException(
// "Callback cannot returned a non-null value as it gets overwritten by the pipeline");
// }
// List<Object> closePipeline = connection.closePipeline();
// pipelinedClosed = true;
// //return SerializationUtils.deserialize(pipeline, resultSerializer);
//
// } finally {
// if (!pipelinedClosed) {
// connection.closePipeline();
// }
// }
// }
// });
// }
protected RedisConnection createRedisConnectionProxy(RedisConnection pm) {
Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), getClass().getClassLoader());