DATAREDIS-1085 - Polishing.
Add author and since tags. Introduce separate approximate() method instead of changing count(…) to retain backwards compatibility. Original pull request: #561.
This commit is contained in:
@@ -57,6 +57,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Tugdual Grall
|
||||
* @author Dengliming
|
||||
* @since 2.2
|
||||
*/
|
||||
public interface ReactiveStreamCommands {
|
||||
@@ -1402,10 +1403,30 @@ public interface ReactiveStreamCommands {
|
||||
* properties.
|
||||
*
|
||||
* @param count
|
||||
* @param approximateTrimming
|
||||
* @return a new {@link TrimCommand} with {@literal count} applied.
|
||||
*/
|
||||
public TrimCommand to(long count, boolean approximateTrimming) {
|
||||
public TrimCommand to(long count) {
|
||||
return new TrimCommand(getKey(), count, approximateTrimming);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies approximate trimming. Constructs a new command instance with all previously configured properties.
|
||||
*
|
||||
* @return a new {@link TrimCommand} with {@literal approximateTrimming} applied.
|
||||
* @since 2.4
|
||||
*/
|
||||
public TrimCommand approximate() {
|
||||
return approximate(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies {@code approximateTrimming}. Constructs a new command instance with all previously configured properties.
|
||||
*
|
||||
* @param approximateTrimming
|
||||
* @return a new {@link TrimCommand} with {@literal approximateTrimming} applied.
|
||||
* @since 2.4
|
||||
*/
|
||||
public TrimCommand approximate(boolean approximateTrimming) {
|
||||
return new TrimCommand(getKey(), count, approximateTrimming);
|
||||
}
|
||||
|
||||
@@ -1441,13 +1462,15 @@ public interface ReactiveStreamCommands {
|
||||
* @param count length of the stream.
|
||||
* @param approximateTrimming the trimming must be performed in a approximated way in order to maximize performances.
|
||||
* @return {@link Mono} emitting the number of removed entries.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
|
||||
*/
|
||||
default Mono<Long> xTrim(ByteBuffer key, long count, boolean approximateTrimming) {
|
||||
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
|
||||
return xTrim(Mono.just(TrimCommand.stream(key).to(count, approximateTrimming))).next().map(NumericResponse::getOutput);
|
||||
return xTrim(Mono.just(TrimCommand.stream(key).to(count).approximate(approximateTrimming))).next()
|
||||
.map(NumericResponse::getOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Tugdual Grall
|
||||
* @author Dengliming
|
||||
* @see <a href="https://redis.io/topics/streams-intro">Redis Documentation - Streams</a>
|
||||
* @since 2.2
|
||||
*/
|
||||
@@ -136,7 +137,7 @@ public interface RedisStreamCommands {
|
||||
|
||||
/**
|
||||
* Limit the size of the stream to the given maximum number of elements.
|
||||
*
|
||||
*
|
||||
* @return new instance of {@link XAddOptions}.
|
||||
*/
|
||||
public static XAddOptions maxlen(long maxlen) {
|
||||
@@ -145,7 +146,7 @@ public interface RedisStreamCommands {
|
||||
|
||||
/**
|
||||
* Limit the size of the stream to the given maximum number of elements.
|
||||
*
|
||||
*
|
||||
* @return can be {@literal null}.
|
||||
*/
|
||||
@Nullable
|
||||
@@ -513,7 +514,7 @@ public interface RedisStreamCommands {
|
||||
|
||||
/**
|
||||
* Obtain general information about the stream stored at the specified {@literal key}.
|
||||
*
|
||||
*
|
||||
* @param key the {@literal key} the stream is stored at.
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.3
|
||||
@@ -881,6 +882,7 @@ public interface RedisStreamCommands {
|
||||
* @param count length of the stream.
|
||||
* @param approximateTrimming the trimming must be performed in a approximated way in order to maximize performances.
|
||||
* @return number of removed entries. {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -62,6 +62,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @author Mark Paluch
|
||||
* @author Ninad Divadkar
|
||||
* @author Tugdual Grall
|
||||
* @author Dengliming
|
||||
* @see RedisCallback
|
||||
* @see RedisSerializer
|
||||
* @see StringRedisTemplate
|
||||
@@ -2467,7 +2468,7 @@ public interface StringRedisConnection extends RedisConnection {
|
||||
* @param count length of the stream.
|
||||
* @param approximateTrimming the trimming must be performed in a approximated way in order to maximize performances.
|
||||
* @return number of removed entries. {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.2
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Tugdual Grall
|
||||
* @author Dengliming
|
||||
* @since 2.2
|
||||
*/
|
||||
class LettuceReactiveStreamCommands implements ReactiveStreamCommands {
|
||||
|
||||
@@ -19,12 +19,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.stream.Consumer;
|
||||
import org.springframework.data.redis.connection.stream.MapRecord;
|
||||
import org.springframework.data.redis.connection.stream.ReadOffset;
|
||||
import org.springframework.data.redis.connection.stream.RecordId;
|
||||
import org.springframework.data.redis.connection.stream.StreamReadOptions;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
@@ -32,6 +32,7 @@ import org.springframework.lang.Nullable;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Dengliming
|
||||
* @since 2.2
|
||||
*/
|
||||
public interface BoundStreamOperations<K, HK, HV> {
|
||||
@@ -215,6 +216,7 @@ public interface BoundStreamOperations<K, HK, HV> {
|
||||
* @param count length of the stream.
|
||||
* @param approximateTrimming the trimming must be performed in a approximated way in order to maximize performances.
|
||||
* @return number of removed entries. {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Dengliming
|
||||
* @since 2.2
|
||||
*/
|
||||
public interface ReactiveStreamOperations<K, HK, HV> extends HashMapperProvider<HK, HV> {
|
||||
@@ -551,6 +552,7 @@ public interface ReactiveStreamOperations<K, HK, HV> extends HashMapperProvider<
|
||||
* @param count length of the stream.
|
||||
* @param approximateTrimming the trimming must be performed in a approximated way in order to maximize performances.
|
||||
* @return number of removed entries.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
|
||||
*/
|
||||
Mono<Long> trim(K key, long count, boolean approximateTrimming);
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Dengliming
|
||||
* @since 2.2
|
||||
*/
|
||||
public interface StreamOperations<K, HK, HV> extends HashMapperProvider<HK, HV> {
|
||||
@@ -532,6 +533,7 @@ public interface StreamOperations<K, HK, HV> extends HashMapperProvider<HK, HV>
|
||||
* @param count length of the stream.
|
||||
* @param approximateTrimming the trimming must be performed in a approximated way in order to maximize performances.
|
||||
* @return number of removed entries. {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.4
|
||||
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: XTRIM</a>
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user