|
22 | 22 | import java.util.List; |
23 | 23 | import java.util.Map; |
24 | 24 | import java.util.stream.Collectors; |
25 | | - |
26 | 25 | import org.jspecify.annotations.NonNull; |
27 | 26 | import org.jspecify.annotations.NullMarked; |
28 | 27 | import org.jspecify.annotations.NullUnmarked; |
29 | 28 | import org.jspecify.annotations.Nullable; |
30 | | - |
31 | 29 | import org.springframework.data.domain.Range; |
32 | 30 | import org.springframework.data.redis.connection.stream.*; |
33 | 31 | import org.springframework.data.redis.connection.stream.StreamInfo.XInfoConsumers; |
@@ -113,30 +111,53 @@ default RecordId xAdd(@NonNull MapRecord<byte[], byte[], byte[]> record) { |
113 | 111 | */ |
114 | 112 | RecordId xAdd(MapRecord<byte[], byte[], byte[]> record, @NonNull XAddOptions options); |
115 | 113 |
|
116 | | - |
| 114 | + /** |
| 115 | + * The trimming strategy. |
| 116 | + * @since 4.1 |
| 117 | + */ |
117 | 118 | sealed interface TrimStrategy permits MaxLenTrimStrategy, MinIdTrimStrategy { |
118 | 119 | } |
119 | 120 |
|
| 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 | + */ |
120 | 126 | final class MaxLenTrimStrategy implements TrimStrategy { |
121 | 127 | private final long threshold; |
122 | 128 |
|
123 | 129 | private MaxLenTrimStrategy(long threshold) { |
124 | 130 | this.threshold = threshold; |
125 | 131 | } |
126 | 132 |
|
| 133 | + /** |
| 134 | + * The maximum number of entries allowed in the stream. |
| 135 | + * |
| 136 | + * @return non-negative number of entries allowed in the stream |
| 137 | + */ |
127 | 138 | public long threshold() { |
128 | 139 | return threshold; |
129 | 140 | } |
130 | 141 |
|
131 | 142 | } |
132 | 143 |
|
| 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 | + */ |
133 | 149 | final class MinIdTrimStrategy implements TrimStrategy { |
134 | 150 | private final RecordId threshold; |
135 | 151 |
|
136 | 152 | private MinIdTrimStrategy(RecordId threshold) { |
137 | 153 | this.threshold = threshold; |
138 | 154 | } |
139 | 155 |
|
| 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 | + */ |
140 | 161 | public RecordId threshold() { |
141 | 162 | return threshold; |
142 | 163 | } |
|
0 commit comments