Interface ListOperations<K,V>
@NullUnmarked
public interface ListOperations<K,V>
Redis list specific operations.
- Author:
- Costin Leau, David Liu, Thomas Darimont, Christoph Strobl, Mark Paluch, dengliming, Lee Jaeheon
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classValue object representing thewhere frompart for theLMOVEcommand.static classValue object representing thewhere tofrom part for theLMOVEcommand. -
Method Summary
Modifier and TypeMethodDescriptiondefault VReturns the first element from the list atkey.default VReturns the last element from the list atkey.@NonNull RedisOperations<K, V> Get element atindexfrom list atkey.Returns the index of the first occurrence of the specified value in the list at atkey.lastIndexOf(@NonNull K key, V value) Returns the index of the last occurrence of the specified value in the list at atkey.Removes and returns first element in list stored atkey.Removes and returns first elements in list stored atkey.Removes and returns first element from lists stored atkey.default VRemoves and returns first element from lists stored atkey.Insertvaluetokeybeforepivot.Prependvaluetokey.leftPushAll(@NonNull K key, @NonNull Collection<V> values) Prependvaluestokey.leftPushAll(@NonNull K key, V @NonNull ... values) Prependvaluestokey.leftPushIfPresent(@NonNull K key, V value) Prependvaluestokeyonly if the list exists.move(@NonNull K sourceKey, @NonNull RedisListCommands.Direction from, @NonNull K destinationKey, @NonNull RedisListCommands.Direction to) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.move(@NonNull K sourceKey, @NonNull RedisListCommands.Direction from, @NonNull K destinationKey, @NonNull RedisListCommands.Direction to, long timeout, @NonNull TimeUnit unit) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.default Vmove(@NonNull K sourceKey, @NonNull RedisListCommands.Direction from, @NonNull K destinationKey, @NonNull RedisListCommands.Direction to, @NonNull Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.default Vmove(@NonNull ListOperations.MoveFrom<K> from, @NonNull ListOperations.MoveTo<K> to) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.default Vmove(@NonNull ListOperations.MoveFrom<K> from, @NonNull ListOperations.MoveTo<K> to, @NonNull Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.Get elements betweenbeginandendfrom list atkey.Removes the firstcountoccurrences ofvaluefrom the list stored atkey.Removes and returns last element in list stored atkey.Removes and returns last elements in list stored atkey.Removes and returns last element from lists stored atkey.default VRemoves and returns last element from lists stored atkey.rightPopAndLeftPush(@NonNull K sourceKey, @NonNull K destinationKey) Remove the last element from list atsourceKey, append it todestinationKeyand return its value.rightPopAndLeftPush(@NonNull K sourceKey, @NonNull K destinationKey, long timeout, @NonNull TimeUnit unit) Remove the last element from list atsourceKey, append it todestinationKeyand return its value.
Blocks connection until element available ortimeoutreached.default VrightPopAndLeftPush(@NonNull K sourceKey, @NonNull K destinationKey, @NonNull Duration timeout) Remove the last element from list atsourceKey, append it todestinationKeyand return its value.
Blocks connection until element available ortimeoutreached.Insertvaluetokeyafterpivot.Appendvaluetokey.rightPushAll(@NonNull K key, @NonNull Collection<V> values) Appendvaluestokey.rightPushAll(@NonNull K key, V @NonNull ... values) Appendvaluestokey.rightPushIfPresent(@NonNull K key, V value) Appendvaluestokeyonly if the list exists.voidSet thevaluelist element atindex.Get the size of list stored atkey.voidTrim list atkeyto elements betweenstartandend.
-
Method Details
-
range
-
trim
Trim list atkeyto elements betweenstartandend.- Parameters:
key- must not be null.start-end-- See Also:
-
size
-
leftPush
-
leftPushAll
-
leftPushAll
Prependvaluestokey.- Parameters:
key- must not be null.values- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 1.5
- See Also:
-
leftPushIfPresent
-
leftPush
-
rightPush
-
rightPushAll
-
rightPushAll
Appendvaluestokey.- Parameters:
key- must not be null.values-- Returns:
- null when used in pipeline / transaction.
- Since:
- 1.5
- See Also:
-
rightPushIfPresent
-
rightPush
-
move
Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.- Parameters:
from- must not be null.to- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
move
V move(@NonNull K sourceKey, @NonNull RedisListCommands.Direction from, @NonNull K destinationKey, @NonNull RedisListCommands.Direction to) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.- Parameters:
sourceKey- must not be null.from- must not be null.destinationKey- must not be null.to- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
move
default V move(@NonNull ListOperations.MoveFrom<K> from, @NonNull ListOperations.MoveTo<K> to, @NonNull Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.Blocks connection until element available or
timeoutreached.- Parameters:
from- must not be null.to- must not be null.timeout- must not be null or negative.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
move
default V move(@NonNull K sourceKey, @NonNull RedisListCommands.Direction from, @NonNull K destinationKey, @NonNull RedisListCommands.Direction to, @NonNull Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.Blocks connection until element available or
timeoutreached.- Parameters:
sourceKey- must not be null.from- must not be null.destinationKey- must not be null.to- must not be null.timeout- must not be null or negative.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
move
V move(@NonNull K sourceKey, @NonNull RedisListCommands.Direction from, @NonNull K destinationKey, @NonNull RedisListCommands.Direction to, long timeout, @NonNull TimeUnit unit) Atomically returns and removes the first/last element (head/tail depending on thefromargument) of the list stored atsourceKey, and pushes the element at the first/last element (head/tail depending on thetoargument) of the list stored atdestinationKey.Blocks connection until element available or
timeoutreached.- Parameters:
sourceKey- must not be null.from- must not be null.destinationKey- must not be null.to- must not be null.timeout-unit-- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
set
-
remove
-
getFirst
-
getLast
-
index
-
indexOf
Returns the index of the first occurrence of the specified value in the list at atkey.
Requires Redis 6.0.6 or newer.- Parameters:
key- must not be null.value- must not be null.- Returns:
- null when used in pipeline / transaction or when not contained in list.
- Since:
- 2.4
- See Also:
-
lastIndexOf
Returns the index of the last occurrence of the specified value in the list at atkey.
Requires Redis 6.0.6 or newer.- Parameters:
key- must not be null.value- must not be null.- Returns:
- null when used in pipeline / transaction or when not contained in list.
- Since:
- 2.4
- See Also:
-
leftPop
-
leftPop
-
leftPop
-
leftPop
Removes and returns first element from lists stored atkey.
Blocks connection until element available ortimeoutreached.- Parameters:
key- must not be null.timeout- must not be null.- Returns:
- can be null.
- Throws:
IllegalArgumentException- if the timeout is null or negative.- Since:
- 2.3
- See Also:
-
rightPop
-
rightPop
-
rightPop
-
rightPop
-
rightPopAndLeftPush
-
rightPopAndLeftPush
V rightPopAndLeftPush(@NonNull K sourceKey, @NonNull K destinationKey, long timeout, @NonNull TimeUnit unit) Remove the last element from list atsourceKey, append it todestinationKeyand return its value.
Blocks connection until element available ortimeoutreached.- Parameters:
sourceKey- must not be null.destinationKey- must not be null.timeout-unit- must not be null.- Returns:
- can be null.
- See Also:
-
rightPopAndLeftPush
default V rightPopAndLeftPush(@NonNull K sourceKey, @NonNull K destinationKey, @NonNull Duration timeout) Remove the last element from list atsourceKey, append it todestinationKeyand return its value.
Blocks connection until element available ortimeoutreached.- Parameters:
sourceKey- must not be null.destinationKey- must not be null.timeout- must not be null.- Returns:
- can be null.
- Throws:
IllegalArgumentException- if the timeout is null or negative.- Since:
- 2.3
- See Also:
-
getOperations
@NonNull RedisOperations<K,V> getOperations()- Returns:
- the underlying
RedisOperationsused to execute commands.
-