Interface ListOperations<K,V>
public interface ListOperations<K,V>
Redis list specific operations.
- Author:
- Costin Leau, David Liu, Thomas Darimont, Christoph Strobl, Mark Paluch, dengliming
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
Value object representing thewhere from
part for theLMOVE
command.static class
Value object representing thewhere to
from part for theLMOVE
command. -
Method Summary
Modifier and TypeMethodDescriptionGet element atindex
form list atkey
.Returns the index of the first occurrence of the specified value in the list at atkey
.lastIndexOf
(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 V
Removes and returns first element from lists stored atkey
.Prependvalue
tokey
.Insertvalue
tokey
beforepivot
.leftPushAll
(K key, Collection<V> values) Prependvalues
tokey
.leftPushAll
(K key, V... values) Prependvalues
tokey
.leftPushIfPresent
(K key, V value) Prependvalues
tokey
only if the list exists.move
(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.move
(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, long timeout, TimeUnit unit) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.default V
move
(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.default V
move
(ListOperations.MoveFrom<K> from, ListOperations.MoveTo<K> to) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.default V
move
(ListOperations.MoveFrom<K> from, ListOperations.MoveTo<K> to, Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.Get elements betweenbegin
andend
from list atkey
.Removes the firstcount
occurrences ofvalue
from 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 V
Removes and returns last element from lists stored atkey
.rightPopAndLeftPush
(K sourceKey, K destinationKey) Remove the last element from list atsourceKey
, append it todestinationKey
and return its value.rightPopAndLeftPush
(K sourceKey, K destinationKey, long timeout, TimeUnit unit) Remove the last element from list atsourceKey
, append it todestinationKey
and return its value.
Blocks connection until element available ortimeout
reached.default V
rightPopAndLeftPush
(K sourceKey, K destinationKey, Duration timeout) Remove the last element from list atsourceKey
, append it todestinationKey
and return its value.
Blocks connection until element available ortimeout
reached.Appendvalue
tokey
.Insertvalue
tokey
afterpivot
.rightPushAll
(K key, Collection<V> values) Appendvalues
tokey
.rightPushAll
(K key, V... values) Appendvalues
tokey
.rightPushIfPresent
(K key, V value) Appendvalues
tokey
only if the list exists.void
Set thevalue
list element atindex
.Get the size of list stored atkey
.void
Trim list atkey
to elements betweenstart
andend
.
-
Method Details
-
range
Get elements betweenbegin
andend
from list atkey
.- Parameters:
key
- must not be null.start
-end
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
trim
Trim list atkey
to elements betweenstart
andend
.- Parameters:
key
- must not be null.start
-end
-- See Also:
-
size
Get the size of list stored atkey
.- Parameters:
key
- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
leftPush
Prependvalue
tokey
.- Parameters:
key
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
leftPushAll
Prependvalues
tokey
.- Parameters:
key
- must not be null.values
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
leftPushAll
Prependvalues
tokey
.- Parameters:
key
- must not be null.values
- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 1.5
- See Also:
-
leftPushIfPresent
Prependvalues
tokey
only if the list exists.- Parameters:
key
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
leftPush
Insertvalue
tokey
beforepivot
.- Parameters:
key
- must not be null.pivot
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
rightPush
Appendvalue
tokey
.- Parameters:
key
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
rightPushAll
Appendvalues
tokey
.- Parameters:
key
- must not be null.values
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
rightPushAll
Appendvalues
tokey
.- Parameters:
key
- must not be null.values
-- Returns:
- null when used in pipeline / transaction.
- Since:
- 1.5
- See Also:
-
rightPushIfPresent
Appendvalues
tokey
only if the list exists.- Parameters:
key
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
rightPush
Insertvalue
tokey
afterpivot
.- Parameters:
key
- must not be null.pivot
- must not be null.value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
move
Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) 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
@Nullable V move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) 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
@Nullable default V move(ListOperations.MoveFrom<K> from, ListOperations.MoveTo<K> to, Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.Blocks connection until element available or
timeout
reached.- 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
@Nullable default V move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, Duration timeout) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.Blocks connection until element available or
timeout
reached.- 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
@Nullable V move(K sourceKey, RedisListCommands.Direction from, K destinationKey, RedisListCommands.Direction to, long timeout, TimeUnit unit) Atomically returns and removes the first/last element (head/tail depending on thefrom
argument) of the list stored atsourceKey
, and pushes the element at the first/last element (head/tail depending on theto
argument) of the list stored atdestinationKey
.Blocks connection until element available or
timeout
reached.- 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
Set thevalue
list element atindex
.- Parameters:
key
- must not be null.index
-value
-- See Also:
-
remove
Removes the firstcount
occurrences ofvalue
from the list stored atkey
.- Parameters:
key
- must not be null.count
-value
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
index
Get element atindex
form list atkey
.- Parameters:
key
- must not be null.index
-- Returns:
- null when used in pipeline / transaction.
- See Also:
-
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
Removes and returns first element in list stored atkey
.- Parameters:
key
- must not be null.- Returns:
- can be null.
- See Also:
-
leftPop
Removes and returns first elements in list stored atkey
.- Parameters:
key
- must not be null.count
-- Returns:
- can be null.
- Since:
- 2.6
- See Also:
-
leftPop
Removes and returns first element from lists stored atkey
.
Blocks connection until element available ortimeout
reached.- Parameters:
key
- must not be null.timeout
-unit
- must not be null.- Returns:
- can be null.
- See Also:
-
leftPop
Removes and returns first element from lists stored atkey
.
Blocks connection until element available ortimeout
reached.- 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
Removes and returns last element in list stored atkey
.- Parameters:
key
- must not be null.- Returns:
- can be null.
- See Also:
-
rightPop
Removes and returns last elements in list stored atkey
.- Parameters:
key
- must not be null.count
-- Returns:
- can be null.
- Since:
- 2.6
- See Also:
-
rightPop
Removes and returns last element from lists stored atkey
.
Blocks connection until element available ortimeout
reached.- Parameters:
key
- must not be null.timeout
-unit
- must not be null.- Returns:
- can be null.
- See Also:
-
rightPop
Removes and returns last element from lists stored atkey
.
Blocks connection until element available ortimeout
reached.- Parameters:
key
- must not be null.timeout
- must not be null.- Returns:
- can be null.
- Since:
- 2.3
- See Also:
-
rightPopAndLeftPush
Remove the last element from list atsourceKey
, append it todestinationKey
and return its value.- Parameters:
sourceKey
- must not be null.destinationKey
- must not be null.- Returns:
- can be null.
- See Also:
-
rightPopAndLeftPush
Remove the last element from list atsourceKey
, append it todestinationKey
and return its value.
Blocks connection until element available ortimeout
reached.- Parameters:
sourceKey
- must not be null.destinationKey
- must not be null.timeout
-unit
- must not be null.- Returns:
- can be null.
- See Also:
-
rightPopAndLeftPush
Remove the last element from list atsourceKey
, append it todestinationKey
and return its value.
Blocks connection until element available ortimeout
reached.- 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
RedisOperations<K,V> getOperations()
-