Interface RedisListCommands
- All Known Subinterfaces:
DefaultedRedisClusterConnection, DefaultedRedisConnection, RedisClusterConnection, RedisCommands, RedisConnection, RedisConnectionUtils.RedisConnectionProxy, StringRedisConnection
- All Known Implementing Classes:
AbstractRedisConnection, DefaultStringRedisConnection, JedisClusterConnection, JedisConnection, LettuceClusterConnection, LettuceConnection
List-specific commands supported by Redis.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch, dengliming
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumList move direction.static enumList insertion position. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]bLMove(byte @NonNull [] sourceKey, byte @NonNull [] destinationKey, @NonNull RedisListCommands.Direction from, @NonNull RedisListCommands.Direction to, double 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.Removes and returns first element from lists stored atkeys.Removes and returns last element from lists stored atkeys.byte[]bRPopLPush(int timeout, byte @NonNull [] srcKey, byte @NonNull [] dstKey) Remove the last element from list atsrcKey, append it todstKeyand return its value.byte[]Get element atindexform list atkey.lInsert(byte @NonNull [] key, @NonNull RedisListCommands.Position where, byte @NonNull [] pivot, byte @NonNull [] value) InsertvalueRedisListCommands.Position.BEFOREorRedisListCommands.Position.AFTERexistingpivotforkey.Get the size of list stored atkey.byte[]lMove(byte @NonNull [] sourceKey, byte @NonNull [] destinationKey, @NonNull RedisListCommands.Direction from, @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.byte[]Removes and returns first element in list stored atkey.Removes and returns first elements in list stored atkey.default LongReturns the index of matching elements inside the list stored at given key.lPos(byte @NonNull [] key, byte @NonNull [] element, @Nullable Integer rank, @Nullable Integer count) Returns the index of matching elements inside the list stored at given key.Prependvaluestokey.Prependvaluestokeyonly if the list exists.Get elements betweenstartandendfrom list atkey.Removes the firstcountoccurrences ofvaluefrom the list stored atkey.voidSet thevaluelist element atindex.voidTrim list atkeyto elements betweenstartandend.byte[]Removes and returns last element in list stored atkey.Removes and returns last elements in list stored atkey.byte[]Remove the last element from list atsrcKey, append it todstKeyand return its value.Appendvaluestokey.Appendvaluestokeyonly if the list exists.
-
Method Details
-
rPush
-
lPos
Returns the index of matching elements inside the list stored at given key.
Requires Redis 6.0.6 or newer.- Parameters:
key- must not be null.element- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.4
- See Also:
-
lPos
List<Long> lPos(byte @NonNull [] key, byte @NonNull [] element, @Nullable Integer rank, @Nullable Integer count) Returns the index of matching elements inside the list stored at given key.
Requires Redis 6.0.6 or newer.- Parameters:
key- must not be null.element- must not be null.rank- specifies the "rank" of the first element to return, in case there are multiple matches. A rank of 1 means to return the first match, 2 to return the second match, and so forth.count- number of matches to return.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.4
- See Also:
-
lPush
-
rPushX
-
lPushX
-
lLen
-
lRange
Get elements betweenstartandendfrom list atkey.- Parameters:
key- must not be null.start-end-- Returns:
- empty
Listif key does not exists or range does not contain values. null when used in pipeline / transaction. - See Also:
-
lTrim
Trim list atkeyto elements betweenstartandend.- Parameters:
key- must not be null.start-end-- See Also:
-
lIndex
Get element atindexform list atkey.- Parameters:
key- must not be null.index- zero based index value. Use negative number to designate elements starting at the tail.- Returns:
- null when index is out of range or when used in pipeline / transaction.
- See Also:
-
lInsert
Long lInsert(byte @NonNull [] key, @NonNull RedisListCommands.Position where, byte @NonNull [] pivot, byte @NonNull [] value) InsertvalueRedisListCommands.Position.BEFOREorRedisListCommands.Position.AFTERexistingpivotforkey.- Parameters:
key- must not be null.where- must not be null.pivot- must not be null.value- must not be null.- Returns:
- null when used in pipeline / transaction.
- See Also:
-
lMove
byte[] lMove(byte @NonNull [] sourceKey, byte @NonNull [] destinationKey, @NonNull RedisListCommands.Direction from, @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.destinationKey- must not be null.from- must not be null.to- must not be null.- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
bLMove
byte[] bLMove(byte @NonNull [] sourceKey, byte @NonNull [] destinationKey, @NonNull RedisListCommands.Direction from, @NonNull RedisListCommands.Direction to, double 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.destinationKey- must not be null.from- must not be null.to- must not be null.timeout-- Returns:
- null when used in pipeline / transaction.
- Since:
- 2.6
- See Also:
-
lSet
-
lRem
-
lPop
Removes and returns first element in list stored atkey.- Parameters:
key- must not be null.- Returns:
- null when key does not exist or used in pipeline / transaction.
- See Also:
-
lPop
-
rPop
Removes and returns last element in list stored atkey.- Parameters:
key- must not be null.- Returns:
- null when key does not exist or used in pipeline / transaction.
- See Also:
-
rPop
-
bLPop
Removes and returns first element from lists stored atkeys.
Blocks connection until element available ortimeoutreached.- Parameters:
timeout- seconds to block.keys- must not be null.- Returns:
- empty
Listwhen no element could be popped and the timeout was reached. null when used in pipeline / transaction. - See Also:
-
bRPop
Removes and returns last element from lists stored atkeys.
Blocks connection until element available ortimeoutreached.- Parameters:
timeout- seconds to block.keys- must not be null.- Returns:
- empty
Listwhen no element could be popped and the timeout was reached. null when used in pipeline / transaction. - See Also:
-
rPopLPush
-
bRPopLPush
Remove the last element from list atsrcKey, append it todstKeyand return its value.
Blocks connection until element available ortimeoutreached.- Parameters:
timeout- seconds to block.srcKey- must not be null.dstKey- must not be null.- Returns:
- can be null.
- See Also:
-