DATAREDIS-1011 - Polishing.

Fix copyright headers and update documentation.

Original Pull Request: #511
This commit is contained in:
Christoph Strobl
2020-03-09 10:57:39 +01:00
parent 42ad8d190d
commit 9b0d405fdf
5 changed files with 39 additions and 14 deletions

View File

@@ -22,6 +22,18 @@ List<Object> results = stringRedisTemplate.executePipelined(
The preceding example runs a bulk right pop of items from a queue in a pipeline. The `results` `List` contains all of the popped items. `RedisTemplate` uses its value, hash key, and hash value serializers to deserialize all results before returning, so the returned items in the preceding example are Strings. There are additional `executePipelined` methods that let you pass a custom serializer for pipelined results.
Note that the value returned from the `RedisCallback` is required to be null, as this value is discarded in favor of returning the results of the pipelined commands.
Note that the value returned from the `RedisCallback` is required to be `null`, as this value is discarded in favor of returning the results of the pipelined commands.
[TIP]
====
The Lettuce driver supports fine grained flush control that allows to either flush commands as they appear, buffer or send them at connection close.
[source,java]
----
LettuceConnectionFactory factory = // ...
factory.setPipeliningFlushPolicy(PipeliningFlushPolicy.buffered(3)); <1>
----
<1> Buffer locally and flush after every 3rd command.
====
include::version-note.adoc[]

View File

@@ -65,9 +65,9 @@ import org.springframework.data.redis.ExceptionTranslationStrategy;
import org.springframework.data.redis.FallbackExceptionTranslationStrategy;
import org.springframework.data.redis.connection.*;
import org.springframework.data.redis.connection.convert.TransactionResultConverter;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionProvider.TargetAware;
import org.springframework.data.redis.connection.lettuce.LettuceResult.LettuceResultBuilder;
import org.springframework.data.redis.connection.lettuce.LettuceResult.LettuceStatusResult;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionProvider.TargetAware;
import org.springframework.data.redis.core.RedisCommand;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -518,6 +518,7 @@ public class LettuceConnection extends AbstractRedisConnection {
*/
@Override
public void openPipeline() {
if (!isPipelined) {
isPipelined = true;
ppline = new ArrayList<>();
@@ -877,6 +878,7 @@ public class LettuceConnection extends AbstractRedisConnection {
* @see PipeliningFlushPolicy#flushEachCommand()
* @see #openPipeline()
* @see StatefulRedisConnection#flushCommands()
* @since 2.3
*/
public void setPipeliningFlushPolicy(PipeliningFlushPolicy pipeliningFlushPolicy) {
@@ -923,15 +925,14 @@ public class LettuceConnection extends AbstractRedisConnection {
}
void pipeline(LettuceResult result) {
if (flushState != null) {
flushState.onCommand(getOrCreateDedicatedConnection());
}
if (isQueueing()) {
if (flushState != null) {
flushState.onCommand(getOrCreateDedicatedConnection());
}
transaction(result);
} else {
flushState.onCommand(getOrCreateDedicatedConnection());
ppline.add(result);
}
}
@@ -1361,6 +1362,8 @@ public class LettuceConnection extends AbstractRedisConnection {
*
* @see StatefulRedisConnection#setAutoFlushCommands(boolean)
* @see StatefulRedisConnection#flushCommands()
* @author Mark Paluch
* @since 2.3
*/
public interface PipeliningFlushPolicy {
@@ -1401,6 +1404,9 @@ public class LettuceConnection extends AbstractRedisConnection {
/**
* State object associated with flushing of the currently ongoing pipeline.
*
* @author Mark Paluch
* @since 2.3
*/
public interface PipeliningFlushState {
@@ -1431,6 +1437,8 @@ public class LettuceConnection extends AbstractRedisConnection {
/**
* Implementation to flush on each command.
* @author Mark Paluch
* @since 2.3
*/
private enum FlushEachCommand implements PipeliningFlushPolicy, PipeliningFlushState {
@@ -1453,6 +1461,8 @@ public class LettuceConnection extends AbstractRedisConnection {
/**
* Implementation to flush on closing the pipeline.
* @author Mark Paluch
* @since 2.3
*/
private enum FlushOnClose implements PipeliningFlushPolicy, PipeliningFlushState {
@@ -1475,13 +1485,15 @@ public class LettuceConnection extends AbstractRedisConnection {
@Override
public void onClose(StatefulConnection<?, ?> connection) {
connection.setAutoFlushCommands(true);
connection.flushCommands();
connection.setAutoFlushCommands(true);
}
}
/**
* Pipeline state for buffered flushing.
* @author Mark Paluch
* @since 2.3
*/
private static class BufferedFlushing implements PipeliningFlushState {
@@ -1507,8 +1519,8 @@ public class LettuceConnection extends AbstractRedisConnection {
@Override
public void onClose(StatefulConnection<?, ?> connection) {
connection.setAutoFlushCommands(true);
connection.flushCommands();
connection.setAutoFlushCommands(true);
}
}
}

View File

@@ -560,12 +560,13 @@ public class LettuceConnectionFactory
}
/**
* Configures the flushing policy when using pipelining. Defaults to {@link PipeliningFlushPolicy#flushEachCommand()
* flush on each command}.
* Configures the flushing policy when using pipelining. If not set, defaults to
* {@link PipeliningFlushPolicy#flushEachCommand() flush on each command}.
*
* @param pipeliningFlushPolicy the flushing policy to control when commands get written to the Redis connection.
* @see LettuceConnection#openPipeline()
* @see StatefulRedisConnection#flushCommands()
* @since 2.3
*/
public void setPipeliningFlushPolicy(PipeliningFlushPolicy pipeliningFlushPolicy) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2020 the original author or authors.
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2020 the original author or authors.
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.