Skip to content

Commit 1d561fc

Browse files
committed
Add javadoc for newly added TrimStrategy interface and sealed impls.
Signed-off-by: Chris Bono <chris.bono@broadcom.com>
1 parent 3d71f97 commit 1d561fc

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/main/java/org/springframework/data/redis/connection/RedisStreamCommands.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222
import java.util.List;
2323
import java.util.Map;
2424
import java.util.stream.Collectors;
25-
2625
import org.jspecify.annotations.NonNull;
2726
import org.jspecify.annotations.NullMarked;
2827
import org.jspecify.annotations.NullUnmarked;
2928
import org.jspecify.annotations.Nullable;
30-
3129
import org.springframework.data.domain.Range;
3230
import org.springframework.data.redis.connection.stream.*;
3331
import org.springframework.data.redis.connection.stream.StreamInfo.XInfoConsumers;
@@ -113,30 +111,53 @@ default RecordId xAdd(@NonNull MapRecord<byte[], byte[], byte[]> record) {
113111
*/
114112
RecordId xAdd(MapRecord<byte[], byte[], byte[]> record, @NonNull XAddOptions options);
115113

116-
114+
/**
115+
* The trimming strategy.
116+
* @since 4.1
117+
*/
117118
sealed interface TrimStrategy permits MaxLenTrimStrategy, MinIdTrimStrategy {
118119
}
119120

121+
/**
122+
* Trimming strategy that evicts entries as long as the stream's length exceeds the specified threshold.
123+
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: MAXLEN option for XTRIM</a>
124+
* @since 4.1
125+
*/
120126
final class MaxLenTrimStrategy implements TrimStrategy {
121127
private final long threshold;
122128

123129
private MaxLenTrimStrategy(long threshold) {
124130
this.threshold = threshold;
125131
}
126132

133+
/**
134+
* The maximum number of entries allowed in the stream.
135+
*
136+
* @return non-negative number of entries allowed in the stream
137+
*/
127138
public long threshold() {
128139
return threshold;
129140
}
130141

131142
}
132143

144+
/**
145+
* Trimming strategy that evicts entries with IDs lower than the specified threshold.
146+
* @see <a href="https://redis.io/commands/xtrim">Redis Documentation: MINID option for XTRIM</a>
147+
* @since 4.1
148+
*/
133149
final class MinIdTrimStrategy implements TrimStrategy {
134150
private final RecordId threshold;
135151

136152
private MinIdTrimStrategy(RecordId threshold) {
137153
this.threshold = threshold;
138154
}
139155

156+
/**
157+
* The lowest stream ID allowed in the stream - all entries whose IDs are less than threshold are trimmed.
158+
*
159+
* @return the lowest stream ID allowed in the stream
160+
*/
140161
public RecordId threshold() {
141162
return threshold;
142163
}

0 commit comments

Comments
 (0)