|
24 | 24 | import java.util.concurrent.BlockingDeque;
|
25 | 25 | import java.util.concurrent.TimeUnit;
|
26 | 26 |
|
| 27 | +import org.springframework.data.redis.core.BoundListOperations; |
| 28 | +import org.springframework.data.redis.core.RedisOperations; |
27 | 29 | import org.springframework.data.redis.core.TimeoutUtils;
|
28 | 30 | import org.springframework.lang.Nullable;
|
29 | 31 | import org.springframework.util.Assert;
|
|
37 | 39 | */
|
38 | 40 | public interface RedisList<E> extends RedisCollection<E>, List<E>, BlockingDeque<E> {
|
39 | 41 |
|
| 42 | + /** |
| 43 | + * Constructs a new, uncapped {@link RedisList} instance. |
| 44 | + * |
| 45 | + * @param key Redis key of this list. |
| 46 | + * @param operations {@link RedisOperations} for the value type of this list. |
| 47 | + * @since 2.6 |
| 48 | + */ |
| 49 | + static <E> RedisList<E> create(String key, RedisOperations<String, E> operations) { |
| 50 | + return new DefaultRedisList<>(key, operations); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Constructs a new {@link RedisList} instance. |
| 55 | + * |
| 56 | + * @param key Redis key of this list. |
| 57 | + * @param operations {@link RedisOperations} for the value type of this list. |
| 58 | + * @param maxSize |
| 59 | + * @since 2.6 |
| 60 | + */ |
| 61 | + static <E> RedisList<E> create(String key, RedisOperations<String, E> operations, int maxSize) { |
| 62 | + return new DefaultRedisList<>(key, operations, maxSize); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Constructs a new, uncapped {@link DefaultRedisList} instance. |
| 67 | + * |
| 68 | + * @param boundOps {@link BoundListOperations} for the value type of this list. |
| 69 | + * @since 2.6 |
| 70 | + */ |
| 71 | + static <E> RedisList<E> create(BoundListOperations<String, E> boundOps) { |
| 72 | + return new DefaultRedisList<>(boundOps); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Constructs a new {@link DefaultRedisList} instance. |
| 77 | + * |
| 78 | + * @param boundOps {@link BoundListOperations} for the value type of this list. |
| 79 | + * @param maxSize |
| 80 | + * @since 2.6 |
| 81 | + */ |
| 82 | + static <E> RedisList<E> create(BoundListOperations<String, E> boundOps, int maxSize) { |
| 83 | + return new DefaultRedisList<>(boundOps, maxSize); |
| 84 | + } |
| 85 | + |
40 | 86 | /**
|
41 | 87 | * Atomically returns and removes the first element of the list stored at the bound key, and pushes the element at the
|
42 | 88 | * first/last element (head/tail depending on the {@link Direction destinationPosition} argument) of the list stored
|
@@ -155,7 +201,32 @@ default E moveLastTo(RedisList<E> destination, Direction destinationPosition, Du
|
155 | 201 | @Nullable
|
156 | 202 | E moveLastTo(RedisList<E> destination, Direction destinationPosition, long timeout, TimeUnit unit);
|
157 | 203 |
|
158 |
| - List<E> range(long begin, long end); |
| 204 | + /** |
| 205 | + * Get elements between {@code start} and {@code end} from list at the bound key. |
| 206 | + * |
| 207 | + * @param start |
| 208 | + * @param end |
| 209 | + * @return {@literal null} when used in pipeline / transaction. |
| 210 | + * @see <a href="https://redis.io/commands/lrange">Redis Documentation: LRANGE</a> |
| 211 | + */ |
| 212 | + List<E> range(long start, long end); |
159 | 213 |
|
160 |
| - RedisList<E> trim(int begin, int end); |
| 214 | + /** |
| 215 | + * Trim list at the bound key to elements between {@code start} and {@code end}. |
| 216 | + * |
| 217 | + * @param start |
| 218 | + * @param end |
| 219 | + * @see <a href="https://redis.io/commands/ltrim">Redis Documentation: LTRIM</a> |
| 220 | + */ |
| 221 | + RedisList<E> trim(int start, int end); |
| 222 | + |
| 223 | + /** |
| 224 | + * Trim list at the bound key to elements between {@code start} and {@code end}. |
| 225 | + * |
| 226 | + * @param start |
| 227 | + * @param end |
| 228 | + * @since 2.6 |
| 229 | + * @see <a href="https://redis.io/commands/ltrim">Redis Documentation: LTRIM</a> |
| 230 | + */ |
| 231 | + RedisList<E> trim(long start, long end); |
161 | 232 | }
|
0 commit comments