Package glide.api.commands
Interface ListBaseCommands
-
- All Known Implementing Classes:
BaseClient,GlideClient,GlideClusterClient
public interface ListBaseCommandsSupports commands for the "List Commands" group for standalone and cluster clients.- See Also:
- List Commands
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOUNT_FOR_LIST_VALKEY_APIValkey API keyword used to extract specific count of members from a sorted set.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<GlideString>blmove(GlideString source, GlideString destination, ListDirection wherefrom, ListDirection whereto, double timeout)Blocks the connection until it pops atomically and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.
BLMoveis the blocking variant oflmove(String, String, ListDirection, ListDirection).java.util.concurrent.CompletableFuture<java.lang.String>blmove(java.lang.String source, java.lang.String destination, ListDirection wherefrom, ListDirection whereto, double timeout)Blocks the connection until it pops atomically and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.
BLMoveis the blocking variant oflmove(String, String, ListDirection, ListDirection).java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>>blmpop(GlideString[] keys, ListDirection direction, double timeout)Blocks the connection until it pops one element from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection).java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>>blmpop(GlideString[] keys, ListDirection direction, long count, double timeout)Blocks the connection until it pops one or more elements from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection, long).java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>>blmpop(java.lang.String[] keys, ListDirection direction, double timeout)Blocks the connection until it pops one element from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection).java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>>blmpop(java.lang.String[] keys, ListDirection direction, long count, double timeout)Blocks the connection until it pops one or more elements from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection, long).java.util.concurrent.CompletableFuture<GlideString[]>blpop(GlideString[] keys, double timeout)Pops an element from the head of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.java.util.concurrent.CompletableFuture<java.lang.String[]>blpop(java.lang.String[] keys, double timeout)Pops an element from the head of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.java.util.concurrent.CompletableFuture<GlideString[]>brpop(GlideString[] keys, double timeout)Pops an element from the tail of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.java.util.concurrent.CompletableFuture<java.lang.String[]>brpop(java.lang.String[] keys, double timeout)Pops an element from the tail of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.java.util.concurrent.CompletableFuture<GlideString>lindex(GlideString key, long index)Returns the element atindexfrom the list stored atkey.
The index is zero-based, so0means the first element,1the second element and so on.java.util.concurrent.CompletableFuture<java.lang.String>lindex(java.lang.String key, long index)Returns the element atindexfrom the list stored atkey.
The index is zero-based, so0means the first element,1the second element and so on.java.util.concurrent.CompletableFuture<java.lang.Long>linsert(GlideString key, LInsertOptions.InsertPosition position, GlideString pivot, GlideString element)Insertselementin the list atkeyeither before or after thepivot.java.util.concurrent.CompletableFuture<java.lang.Long>linsert(java.lang.String key, LInsertOptions.InsertPosition position, java.lang.String pivot, java.lang.String element)Insertselementin the list atkeyeither before or after thepivot.java.util.concurrent.CompletableFuture<java.lang.Long>llen(GlideString key)Returns the length of the list stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>llen(java.lang.String key)Returns the length of the list stored atkey.java.util.concurrent.CompletableFuture<GlideString>lmove(GlideString source, GlideString destination, ListDirection wherefrom, ListDirection whereto)Atomically pops and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.java.util.concurrent.CompletableFuture<java.lang.String>lmove(java.lang.String source, java.lang.String destination, ListDirection wherefrom, ListDirection whereto)Atomically pops and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>>lmpop(GlideString[] keys, ListDirection direction)Pops one element from the first non-empty list from the providedkeys.java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>>lmpop(GlideString[] keys, ListDirection direction, long count)Pops one or more elements from the first non-empty list from the providedkeys.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>>lmpop(java.lang.String[] keys, ListDirection direction)Pops one element from the first non-empty list from the providedkeys.java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>>lmpop(java.lang.String[] keys, ListDirection direction, long count)Pops one or more elements from the first non-empty list from the providedkeys.java.util.concurrent.CompletableFuture<GlideString>lpop(GlideString key)Removes and returns the first elements of the list stored atkey.java.util.concurrent.CompletableFuture<java.lang.String>lpop(java.lang.String key)Removes and returns the first elements of the list stored atkey.java.util.concurrent.CompletableFuture<GlideString[]>lpopCount(GlideString key, long count)Removes and returns up tocountelements of the list stored atkey, depending on the list's length.java.util.concurrent.CompletableFuture<java.lang.String[]>lpopCount(java.lang.String key, long count)Removes and returns up tocountelements of the list stored atkey, depending on the list's length.java.util.concurrent.CompletableFuture<java.lang.Long>lpos(@NonNull GlideString key, @NonNull GlideString element, @NonNull LPosOptions options)Returns the index of an occurrence ofelementwithin a list based on the givenoptions.java.util.concurrent.CompletableFuture<java.lang.Long>lpos(@NonNull java.lang.String key, @NonNull java.lang.String element, @NonNull LPosOptions options)Returns the index of an occurrence ofelementwithin a list based on the givenoptions.java.util.concurrent.CompletableFuture<java.lang.Long>lpos(GlideString key, GlideString element)Returns the index of the first occurrence ofelementinside the list specified bykey.java.util.concurrent.CompletableFuture<java.lang.Long>lpos(java.lang.String key, java.lang.String element)Returns the index of the first occurrence ofelementinside the list specified bykey.java.util.concurrent.CompletableFuture<java.lang.Long[]>lposCount(@NonNull GlideString key, @NonNull GlideString element, long count)Returns anarrayof indices of matching elements within a list.java.util.concurrent.CompletableFuture<java.lang.Long[]>lposCount(@NonNull GlideString key, @NonNull GlideString element, long count, @NonNull LPosOptions options)Returns anarrayof indices of matching elements within a list based on the givenoptions.java.util.concurrent.CompletableFuture<java.lang.Long[]>lposCount(@NonNull java.lang.String key, @NonNull java.lang.String element, long count)Returns anarrayof indices of matching elements within a list.java.util.concurrent.CompletableFuture<java.lang.Long[]>lposCount(@NonNull java.lang.String key, @NonNull java.lang.String element, long count, @NonNull LPosOptions options)Returns anarrayof indices of matching elements within a list based on the givenoptions.java.util.concurrent.CompletableFuture<java.lang.Long>lpush(GlideString key, GlideString[] elements)Inserts all the specified values at the head of the list stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>lpush(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the head of the list stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>lpushx(GlideString key, GlideString[] elements)Inserts all the specified values at the head of the list stored atkey, only ifkeyexists and holds a list.java.util.concurrent.CompletableFuture<java.lang.Long>lpushx(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the head of the list stored atkey, only ifkeyexists and holds a list.java.util.concurrent.CompletableFuture<GlideString[]>lrange(GlideString key, long start, long end)Returns the specified elements of the list stored atkey.
The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on.java.util.concurrent.CompletableFuture<java.lang.String[]>lrange(java.lang.String key, long start, long end)Returns the specified elements of the list stored atkey.
The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on.java.util.concurrent.CompletableFuture<java.lang.Long>lrem(GlideString key, long count, GlideString element)Removes the firstcountoccurrences of elements equal toelementfrom the list stored atkey.java.util.concurrent.CompletableFuture<java.lang.Long>lrem(java.lang.String key, long count, java.lang.String element)Removes the firstcountoccurrences of elements equal toelementfrom the list stored atkey.java.util.concurrent.CompletableFuture<java.lang.String>lset(GlideString key, long index, GlideString element)Sets the list element atindextoelement.
The index is zero-based, so0means the first element,1the second element and so on.java.util.concurrent.CompletableFuture<java.lang.String>lset(java.lang.String key, long index, java.lang.String element)Sets the list element atindextoelement.
The index is zero-based, so0means the first element,1the second element and so on.java.util.concurrent.CompletableFuture<java.lang.String>ltrim(GlideString key, long start, long end)Trims an existing list so that it will contain only the specified range of elements specified.java.util.concurrent.CompletableFuture<java.lang.String>ltrim(java.lang.String key, long start, long end)Trims an existing list so that it will contain only the specified range of elements specified.java.util.concurrent.CompletableFuture<GlideString>rpop(GlideString key)Removes and returns the last elements of the list stored atkey.
The command pops a single element from the end of the list.java.util.concurrent.CompletableFuture<java.lang.String>rpop(java.lang.String key)Removes and returns the last elements of the list stored atkey.
The command pops a single element from the end of the list.java.util.concurrent.CompletableFuture<GlideString[]>rpopCount(GlideString key, long count)Removes and returns up tocountelements from the list stored atkey, depending on the list's length.java.util.concurrent.CompletableFuture<java.lang.String[]>rpopCount(java.lang.String key, long count)Removes and returns up tocountelements from the list stored atkey, depending on the list's length.java.util.concurrent.CompletableFuture<java.lang.Long>rpush(GlideString key, GlideString[] elements)Inserts all the specified values at the tail of the list stored atkey.
elementsare inserted one after the other to the tail of the list, from the leftmost element to the rightmost element.java.util.concurrent.CompletableFuture<java.lang.Long>rpush(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the tail of the list stored atkey.
elementsare inserted one after the other to the tail of the list, from the leftmost element to the rightmost element.java.util.concurrent.CompletableFuture<java.lang.Long>rpushx(GlideString key, GlideString[] elements)Inserts all the specified values at the tail of the list stored atkey, only ifkeyexists and holds a list.java.util.concurrent.CompletableFuture<java.lang.Long>rpushx(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the tail of the list stored atkey, only ifkeyexists and holds a list.
-
-
-
Field Detail
-
COUNT_FOR_LIST_VALKEY_API
static final java.lang.String COUNT_FOR_LIST_VALKEY_API
Valkey API keyword used to extract specific count of members from a sorted set.- See Also:
- Constant Field Values
-
-
Method Detail
-
lpush
java.util.concurrent.CompletableFuture<java.lang.Long> lpush(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the head of the list stored atkey.elementsare inserted one after the other to the head of the list, from the leftmost element to the rightmost element. Ifkeydoes not exist, it is created as an empty list before performing the push operation.- Parameters:
key- The key of the list.elements- The elements to insert at the head of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long pushCount1 = client.lpush("my_list", new String[] {"value1", "value2"}).get(); assert pushCount1 == 2L; Long pushCount2 = client.lpush("nonexistent_list", new String[] {"new_value"}).get(); assert pushCount2 == 1L;
-
lpush
java.util.concurrent.CompletableFuture<java.lang.Long> lpush(GlideString key, GlideString[] elements)
Inserts all the specified values at the head of the list stored atkey.elementsare inserted one after the other to the head of the list, from the leftmost element to the rightmost element. Ifkeydoes not exist, it is created as an empty list before performing the push operation.- Parameters:
key- The key of the list.elements- The elements to insert at the head of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long pushCount1 = client.lpush(gs("my_list"), new GlideString[] {gs("value1"), gs("value2")}).get(); assert pushCount1 == 2L; Long pushCount2 = client.lpush(gs("nonexistent_list"), new GlideString[] {gs("new_value")}).get(); assert pushCount2 == 1L;
-
lpop
java.util.concurrent.CompletableFuture<java.lang.String> lpop(java.lang.String key)
Removes and returns the first elements of the list stored atkey. The command pops a single element from the beginning of the list.- Parameters:
key- The key of the list.- Returns:
- The value of the first element.
Ifkeydoes not exist, null will be returned. - See Also:
- valkey.io for details.
- Example:
String value1 = client.lpop("my_list").get(); assert value1.equals("value1"); String value2 = client.lpop("non_exiting_key").get(); assert value2.equals(null);
-
lpop
java.util.concurrent.CompletableFuture<GlideString> lpop(GlideString key)
Removes and returns the first elements of the list stored atkey. The command pops a single element from the beginning of the list.- Parameters:
key- The key of the list.- Returns:
- The value of the first element.
Ifkeydoes not exist, null will be returned. - See Also:
- valkey.io for details.
- Example:
GlideString value1 = client.lpop(gs("my_list")).get(); assert value1.equals(gs("value1")); GlideString value2 = client.lpop(gs("non_exiting_key")).get(); assert value2.equals(null);
-
lpos
java.util.concurrent.CompletableFuture<java.lang.Long> lpos(java.lang.String key, java.lang.String element)Returns the index of the first occurrence ofelementinside the list specified bykey. If no match is found,nullis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.- Returns:
- The index of the first occurrence of
element, ornullifelementis not in the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush("my_list", new String[] {"a", "b", "c", "d", "e", "e"}).get(); Long position = client.lpos("my_list", "e").get(); assert position == 4L;
-
lpos
java.util.concurrent.CompletableFuture<java.lang.Long> lpos(GlideString key, GlideString element)
Returns the index of the first occurrence ofelementinside the list specified bykey. If no match is found,nullis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.- Returns:
- The index of the first occurrence of
element, ornullifelementis not in the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush(gs("my_list"), new GlideString[] {gs("a"), gs("b"), gs("c"), gs("d"), gs("e"), gs("e")}).get(); Long position = client.lpos(gs("my_list"), gs("e")).get(); assert position == 4L;
-
lpos
java.util.concurrent.CompletableFuture<java.lang.Long> lpos(@NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String element, @NonNull @NonNull LPosOptions options)Returns the index of an occurrence ofelementwithin a list based on the givenoptions. If no match is found,nullis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.options- The LPos options.- Returns:
- The index of
element, ornullifelementis not in the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush("my_list", new String[] {"a", "b", "c", "d", "e", "e"}).get(); // Returns the second occurrence of the element "e". LPosOptions options1 = LPosOptions.builder().rank(2L).build(); Long position1 = client.lpos("my_list", "e", options1).get(); assert position1 == 5L; // rank and maxLength LPosOptions options2 = LPosOptions.builder().rank(1L).maxLength(1000L).build(); Long position2 = client.lpos("my_list", "e", options2).get(); assert position2 == 4L;
-
lpos
java.util.concurrent.CompletableFuture<java.lang.Long> lpos(@NonNull @NonNull GlideString key, @NonNull @NonNull GlideString element, @NonNull @NonNull LPosOptions options)Returns the index of an occurrence ofelementwithin a list based on the givenoptions. If no match is found,nullis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.options- The LPos options.- Returns:
- The index of
element, ornullifelementis not in the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush(gs("my_list")), new GlideString[] {gs("a"), gs("b"), gs("c"), gs("d"), gs("e"), gs("e")}).get(); // Returns the second occurrence of the element gs("e"). LPosOptions options1 = LPosOptions.builder().rank(2L).build(); Long position1 = client.lpos(gs("my_list"), gs("e"), options1).get(); assert position1 == 5L; // rank and maxLength LPosOptions options2 = LPosOptions.builder().rank(1L).maxLength(1000L).build(); Long position2 = client.lpos(gs("my_list"), gs("e"), options2).get(); assert position2 == 4L;
-
lposCount
java.util.concurrent.CompletableFuture<java.lang.Long[]> lposCount(@NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String element, long count)Returns anarrayof indices of matching elements within a list.- Parameters:
key- The name of the list.element- The value to search for within the list.count- The number of matches wanted.- Returns:
- An
arraythat holds the indices of the matching elements within the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush("my_list", new String[] {"a", "b", "c", "d", "e", "e", "e"}).get(); Long[] position = client.lposCount("my_list", "e", 3L).get()); assertArrayEquals(new Long[]{4L, 5L, 6L}, position);
-
lposCount
java.util.concurrent.CompletableFuture<java.lang.Long[]> lposCount(@NonNull @NonNull GlideString key, @NonNull @NonNull GlideString element, long count)Returns anarrayof indices of matching elements within a list.- Parameters:
key- The name of the list.element- The value to search for within the list.count- The number of matches wanted.- Returns:
- An
arraythat holds the indices of the matching elements within the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush(gs("my_list"), new GlideString[] {gs("a"), gs("b"), gs("c"), gs("d"), gs("e"), gs("e"), gs("e")}).get(); Long[] position = client.lposCount(gs("my_list"), gs("e"), 3L).get()); assertArrayEquals(new Long[]{4L, 5L, 6L}, position);
-
lposCount
java.util.concurrent.CompletableFuture<java.lang.Long[]> lposCount(@NonNull @NonNull java.lang.String key, @NonNull @NonNull java.lang.String element, long count, @NonNull @NonNull LPosOptions options)Returns anarrayof indices of matching elements within a list based on the givenoptions. If no match is found, an emptyarrayis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.count- The number of matches wanted.options- The LPos options.- Returns:
- An
arraythat holds the indices of the matching elements within the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush("my_list", new String[] {"a", "b", "c", "d", "e", "e", "e"}).get(); // rank LPosOptions options1 = LPosOptions.builder().rank(2L).build(); Long[] position1 = client.lposCount("my_list", "e", 1L, options1).get(); assertArrayEquals(new Long[]{5L}, position1); // rank and maxLength LPosOptions options2 = LPosOptions.builder.rank(2L).maxLength(1000L).build(); Long[] position2 = client.lposCount("my_list", "e", 3L, options2).get(); assertArrayEquals(new Long[]{5L, 6L}, position2);
-
lposCount
java.util.concurrent.CompletableFuture<java.lang.Long[]> lposCount(@NonNull @NonNull GlideString key, @NonNull @NonNull GlideString element, long count, @NonNull @NonNull LPosOptions options)Returns anarrayof indices of matching elements within a list based on the givenoptions. If no match is found, an emptyarrayis returned.- Parameters:
key- The name of the list.element- The value to search for within the list.count- The number of matches wanted.options- The LPos options.- Returns:
- An
arraythat holds the indices of the matching elements within the list. - Since:
- Valkey 6.0.6.
- See Also:
- valkey.io for details.
- Example:
Long listLen = client.rpush(gs("my_list"), new GlideString[] {gs("a"), gs("b"), gs("c"), gs("d"), gs("e"), gs("e"), gs("e")}).get(); // rank LPosOptions options1 = LPosOptions.builder().rank(2L).build(); Long[] position1 = client.lposCount(gs("my_list"), gs("e"), 1L, options1).get(); assertArrayEquals(new Long[]{5L}, position1); // rank and maxLength LPosOptions options2 = LPosOptions.builder.rank(2L).maxLength(1000L).build(); Long[] position2 = client.lposCount(gs("my_list"), gs("e"), 3L, options2).get(); assertArrayEquals(new Long[]{5L, 6L}, position2);
-
lpopCount
java.util.concurrent.CompletableFuture<java.lang.String[]> lpopCount(java.lang.String key, long count)Removes and returns up tocountelements of the list stored atkey, depending on the list's length.- Parameters:
key- The key of the list.count- The count of the elements to pop from the list.- Returns:
- An array of the popped elements will be returned depending on the list's length.
Ifkeydoes not exist, null will be returned. - See Also:
- valkey.io for details.
- Example:
String[] values1 = client.lpopCount("my_list", 2).get(); assert values1.equals(new String[] {"value1", "value2"}); String[] values2 = client.lpopCount("non_exiting_key" , 7).get(); assert values2.equals(null);
-
lpopCount
java.util.concurrent.CompletableFuture<GlideString[]> lpopCount(GlideString key, long count)
Removes and returns up tocountelements of the list stored atkey, depending on the list's length.- Parameters:
key- The key of the list.count- The count of the elements to pop from the list.- Returns:
- An array of the popped elements will be returned depending on the list's length.
Ifkeydoes not exist, null will be returned. - See Also:
- valkey.io for details.
- Example:
GlideString[] values1 = client.lpopCount(gs("my_list"), 2).get(); assert values1.equals(new GlideString[] {gs("value1"), gs("value2")}); GlideString[] values2 = client.lpopCount(gs("non_exiting_key") , 7).get(); assert values2.equals(null);
-
lrange
java.util.concurrent.CompletableFuture<java.lang.String[]> lrange(java.lang.String key, long start, long end)Returns the specified elements of the list stored atkey.
The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the list.start- The starting point of the range.end- The end of the range.- Returns:
- Array of elements in the specified range.
Ifstartexceeds the end of the list, or ifstartis greater thanend, an empty array will be returned.
Ifendexceeds the actual end of the list, the range will stop at the actual end of the list.
Ifkeydoes not exist an empty array will be returned. - See Also:
- valkey.io for details.
- Example:
String[] payload = lient.lrange("my_list", 0, 2).get(); assert payload.equals(new String[] {"value1", "value2", "value3"}); String[] payload = client.lrange("my_list", -2, -1).get(); assert payload.equals(new String[] {"value2", "value3"}); String[] payload = client.lrange("non_exiting_key", 0, 2).get(); assert payload.equals(new String[] {});
-
lrange
java.util.concurrent.CompletableFuture<GlideString[]> lrange(GlideString key, long start, long end)
Returns the specified elements of the list stored atkey.
The offsetsstartandendare zero-based indexes, with0being the first element of the list,1being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list, with-1being the last element of the list,-2being the penultimate, and so on.- Parameters:
key- The key of the list.start- The starting point of the range.end- The end of the range.- Returns:
- Array of elements in the specified range.
Ifstartexceeds the end of the list, or ifstartis greater thanend, an empty array will be returned.
Ifendexceeds the actual end of the list, the range will stop at the actual end of the list.
Ifkeydoes not exist an empty array will be returned. - See Also:
- valkey.io for details.
- Example:
GlideString[] payload = lient.lrange(gs("my_list"), 0, 2).get(); assert Arrays.equals(new GlideString[] {gs("value1"), gs("value2"), gs("value3")}); GlideString[] payload = client.lrange(gs("my_list"), -2, -1).get(); assert Arrays.equals(new GlideString[] {gs("value2"), gs("value3")}); GlideString[] payload = client.lrange(gs("non_exiting_key"), 0, 2).get(); assert Arrays.equals(new GlideString[] {});
-
lindex
java.util.concurrent.CompletableFuture<java.lang.String> lindex(java.lang.String key, long index)Returns the element atindexfrom the list stored atkey.
The index is zero-based, so0means the first element,1the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here,-1means the last element,-2means the penultimate and so forth.- Parameters:
key- The key of the list.index- The index of the element in the list to retrieve.- Returns:
- The element at
indexin the list stored atkey.
Ifindexis out of range or ifkeydoes not exist,nullis returned. - See Also:
- valkey.io for details.
- Example:
String payload1 = client.lindex("myList", 0).get(); assert payload1.equals("value1"); // Returns the first element in the list stored at 'myList'. String payload2 = client.lindex("myList", -1).get(); assert payload2.equals("value3"); // Returns the last element in the list stored at 'myList'.
-
lindex
java.util.concurrent.CompletableFuture<GlideString> lindex(GlideString key, long index)
Returns the element atindexfrom the list stored atkey.
The index is zero-based, so0means the first element,1the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here,-1means the last element,-2means the penultimate and so forth.- Parameters:
key- The key of the list.index- The index of the element in the list to retrieve.- Returns:
- The element at
indexin the list stored atkey.
Ifindexis out of range or ifkeydoes not exist,nullis returned. - See Also:
- valkey.io for details.
- Example:
String payload1 = client.lindex(gs("myList"), 0).get(); assert payload1.equals(gs("value1")); // Returns the first element in the list stored at 'myList'. String payload2 = client.lindex(gs("myList"), -1).get(); assert payload2.equals(gs("value3")); // Returns the last element in the list stored at 'myList'.
-
ltrim
java.util.concurrent.CompletableFuture<java.lang.String> ltrim(java.lang.String key, long start, long end)Trims an existing list so that it will contain only the specified range of elements specified.
The offsetsstartandendare zero-based indexes, with 0 being the first element of the list, 1 being the next element and so on.
These offsets can also be negative numbers indicating offsets starting at the end of the list, with -1 being the last element of the list, -2 being the penultimate, and so on.- Parameters:
key- The key of the list.start- The starting point of the range.end- The end of the range.- Returns:
- Always
OK.
Ifstartexceeds the end of the list, or ifstartis greater thanend, the list is emptied and the key is removed.
Ifendexceeds the actual end of the list, it will be treated like the last element of the list.
Ifkeydoes not exist, OK will be returned without changes to the database. - See Also:
- valkey.io for details.
- Example:
String payload = client.ltrim("my_list", 0, 1).get(); assert payload.equals("OK");
-
ltrim
java.util.concurrent.CompletableFuture<java.lang.String> ltrim(GlideString key, long start, long end)
Trims an existing list so that it will contain only the specified range of elements specified.
The offsetsstartandendare zero-based indexes, with 0 being the first element of the list, 1 being the next element and so on.
These offsets can also be negative numbers indicating offsets starting at the end of the list, with -1 being the last element of the list, -2 being the penultimate, and so on.- Parameters:
key- The key of the list.start- The starting point of the range.end- The end of the range.- Returns:
- Always
OK.
Ifstartexceeds the end of the list, or ifstartis greater thanend, the result will be an empty list (which causes key to be removed).
Ifendexceeds the actual end of the list, it will be treated like the last element of the list.
Ifkeydoes not exist, OK will be returned without changes to the database. - See Also:
- valkey.io for details.
- Example:
String payload = client.ltrim(gs("my_list"), 0, 1).get(); assert payload.equals("OK");
-
llen
java.util.concurrent.CompletableFuture<java.lang.Long> llen(java.lang.String key)
Returns the length of the list stored atkey.- Parameters:
key- The key of the list.- Returns:
- The length of the list at
key.
Ifkeydoes not exist, it is interpreted as an empty list and0is returned. - See Also:
- valkey.io for details.
- Example:
Long lenList = client.llen("my_list").get(); assert lenList == 3L //Indicates that there are 3 elements in the list.;
-
llen
java.util.concurrent.CompletableFuture<java.lang.Long> llen(GlideString key)
Returns the length of the list stored atkey.- Parameters:
key- The key of the list.- Returns:
- The length of the list at
key.
Ifkeydoes not exist, it is interpreted as an empty list and0is returned. - See Also:
- valkey.io for details.
- Example:
Long lenList = client.llen(gs("my_list")).get(); assert lenList == 3L //Indicates that there are 3 elements in the list.;
-
lrem
java.util.concurrent.CompletableFuture<java.lang.Long> lrem(java.lang.String key, long count, java.lang.String element)Removes the firstcountoccurrences of elements equal toelementfrom the list stored atkey.- Parameters:
key- The key of the list.count- The count of the occurrences of elements equal toelementto remove. Ifcountis positive: Removes elements equal toelementmoving from head to tail.
Ifcountis negative: Removes elements equal toelementmoving from tail to head.
Ifcountis 0 orcountis greater than the occurrences of elements equal toelement, it removes all elements equal toelement.`element- The element to remove from the list.- Returns:
- The number of the removed elements.
Ifkeydoes not exist,0is returned. - See Also:
- valkey.io for details.
- Example:
Long num = client.rem("my_list", 2, "value").get(); assert num == 2L;
-
lrem
java.util.concurrent.CompletableFuture<java.lang.Long> lrem(GlideString key, long count, GlideString element)
Removes the firstcountoccurrences of elements equal toelementfrom the list stored atkey.- Parameters:
key- The key of the list.count- The count of the occurrences of elements equal toelementto remove. Ifcountis positive: Removes elements equal toelementmoving from head to tail.
Ifcountis negative: Removes elements equal toelementmoving from tail to head.
Ifcountis 0 orcountis greater than the occurrences of elements equal toelement, it removes all elements equal toelement.`element- The element to remove from the list.- Returns:
- The number of the removed elements.
Ifkeydoes not exist,0is returned. - See Also:
- valkey.io for details.
- Example:
Long num = client.rem(gs("my_list"), 2, gs("value")).get(); assert num == 2L;
-
rpush
java.util.concurrent.CompletableFuture<java.lang.Long> rpush(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the tail of the list stored atkey.
elementsare inserted one after the other to the tail of the list, from the leftmost element to the rightmost element. Ifkeydoes not exist, it is created as an empty list before performing the push operation.- Parameters:
key- The key of the list.elements- The elements to insert at the tail of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long pushCount1 = client.rpush("my_list", new String[] {"value1", "value2"}).get(); assert pushCount1 == 2L; Long pushCount2 = client.rpush("nonexistent_list", new String[] {"new_value"}).get(); assert pushCount2 == 1L;
-
rpush
java.util.concurrent.CompletableFuture<java.lang.Long> rpush(GlideString key, GlideString[] elements)
Inserts all the specified values at the tail of the list stored atkey.
elementsare inserted one after the other to the tail of the list, from the leftmost element to the rightmost element. Ifkeydoes not exist, it is created as an empty list before performing the push operation.- Parameters:
key- The key of the list.elements- The elements to insert at the tail of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long pushCount1 = client.rpush(gs("my_list"), new GlideString[] {gs("value1"), gs("value2")}).get(); assert pushCount1 == 2L; Long pushCount2 = client.rpush(gs("nonexistent_list"), new GlideString[] {gs("new_value")}).get(); assert pushCount2 == 1L;
-
rpop
java.util.concurrent.CompletableFuture<java.lang.String> rpop(java.lang.String key)
Removes and returns the last elements of the list stored atkey.
The command pops a single element from the end of the list.- Parameters:
key- The key of the list.- Returns:
- The value of the last element.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
- Example:
String value1 = client.rpop("my_list").get(); assert value1.equals("value1"); String value2 = client.rpop("non_exiting_key").get(); assert value2.equals(null);
-
rpop
java.util.concurrent.CompletableFuture<GlideString> rpop(GlideString key)
Removes and returns the last elements of the list stored atkey.
The command pops a single element from the end of the list.- Parameters:
key- The key of the list.- Returns:
- The value of the last element.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
- Example:
GlideString value1 = client.rpop(gs("my_list")).get(); assert value1.equals(gs("value1")); GlideString value2 = client.rpop(gs("non_exiting_key")).get(); assert value2.equals(null);
-
rpopCount
java.util.concurrent.CompletableFuture<java.lang.String[]> rpopCount(java.lang.String key, long count)Removes and returns up tocountelements from the list stored atkey, depending on the list's length.- Parameters:
key- The key of the list.count- The count of the elements to pop from the list.- Returns:
- An array of popped elements will be returned depending on the list's length.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
- Example:
String[] values1 = client.rpopCount("my_list", 2).get(); assert values1.equals(new String[] {"value1", "value2"}); String[] values2 = client.rpopCount("non_exiting_key" , 7).get(); assert values2.equals(null);
-
rpopCount
java.util.concurrent.CompletableFuture<GlideString[]> rpopCount(GlideString key, long count)
Removes and returns up tocountelements from the list stored atkey, depending on the list's length.- Parameters:
key- The key of the list.count- The count of the elements to pop from the list.- Returns:
- An array of popped elements will be returned depending on the list's length.
Ifkeydoes not exist,nullwill be returned. - See Also:
- valkey.io for details.
- Example:
GlideString[] values1 = client.rpopCount(gs("my_list"), 2).get(); assert Arrays.equals(values1, new GlideString[] {gs("value1"), gs("value2")}); GlideString[] values2 = client.rpopCount(gs("non_exiting_key"), 7).get(); assert values2.equals(null);
-
linsert
java.util.concurrent.CompletableFuture<java.lang.Long> linsert(java.lang.String key, LInsertOptions.InsertPosition position, java.lang.String pivot, java.lang.String element)Insertselementin the list atkeyeither before or after thepivot.- Parameters:
key- The key of the list.position- The relative position to insert into - eitherLInsertOptions.InsertPosition.BEFOREorLInsertOptions.InsertPosition.AFTERthepivot.pivot- An element of the list.element- The new element to insert.- Returns:
- The list length after a successful insert operation.
If thekeydoesn't exist returns-1.
If thepivotwasn't found, returns0. - See Also:
- valkey.io for details.
- Example:
Long length = client.linsert("my_list", BEFORE, "World", "There").get(); assert length > 0L;
-
linsert
java.util.concurrent.CompletableFuture<java.lang.Long> linsert(GlideString key, LInsertOptions.InsertPosition position, GlideString pivot, GlideString element)
Insertselementin the list atkeyeither before or after thepivot.- Parameters:
key- The key of the list.position- The relative position to insert into - eitherLInsertOptions.InsertPosition.BEFOREorLInsertOptions.InsertPosition.AFTERthepivot.pivot- An element of the list.element- The new element to insert.- Returns:
- The list length after a successful insert operation.
If thekeydoesn't exist returns-1.
If thepivotwasn't found, returns0. - See Also:
- valkey.io for details.
- Example:
Long length = client.linsert(gs("my_list"), BEFORE, gs("World"), gs("There")).get(); assert length > 0L;
-
blpop
java.util.concurrent.CompletableFuture<java.lang.String[]> blpop(java.lang.String[] keys, double timeout)Pops an element from the head of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.- Parameters:
keys- Thekeysof the lists to pop from.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A two-element
arraycontaining thekeyfrom which the element was popped and thevalueof the popped element, formatted as[key, value]. If no element could be popped and the timeout expired, returnsnull. - See Also:
- valkey.io for details.
- Example:
String[] response = client.blpop(["list1", "list2"], 0.5).get(); assert response[0].equals("list1"); assert response[1].equals("element");
-
blpop
java.util.concurrent.CompletableFuture<GlideString[]> blpop(GlideString[] keys, double timeout)
Pops an element from the head of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.- Parameters:
keys- Thekeysof the lists to pop from.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A two-element
arraycontaining thekeyfrom which the element was popped and thevalueof the popped element, formatted as[key, value]. If no element could be popped and the timeout expired, returns null. - See Also:
- valkey.io for details.
- Example:
GlideString[] response = client.blpop([gs("list1"), gs("list2")], 0.5).get(); assert response[0].equals(gs("list1")); assert response[1].equals(gs("element"));
-
brpop
java.util.concurrent.CompletableFuture<java.lang.String[]> brpop(java.lang.String[] keys, double timeout)Pops an element from the tail of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.- Parameters:
keys- Thekeysof the lists to pop from.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A two-element
arraycontaining thekeyfrom which the element was popped and thevalueof the popped element, formatted as[key, value]. If no element could be popped and the timeout expired, returnsnull. - See Also:
- valkey.io for details.
- Example:
String[] response = client.brpop(["list1", "list2"], 0.5).get(); assert response[0].equals("list1"); assert response[1].equals("element");
-
brpop
java.util.concurrent.CompletableFuture<GlideString[]> brpop(GlideString[] keys, double timeout)
Pops an element from the tail of the first list that is non-empty, with the givenkeysbeing checked in the order that they are given.
Blocks the connection when there are no elements to pop from any of the given lists.- Parameters:
keys- Thekeysof the lists to pop from.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A two-element
arraycontaining thekeyfrom which the element was popped and thevalueof the popped element, formatted as[key, value]. If no element could be popped and the timeout expired, returns null. - See Also:
- valkey.io for details.
- Example:
GlideString[] response = client.brpop([gs("list1"), gs("list2")], 0.5).get(); assert response[0].equals(gs("list1")); assert response[1].equals(gs("element"));
-
rpushx
java.util.concurrent.CompletableFuture<java.lang.Long> rpushx(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the tail of the list stored atkey, only ifkeyexists and holds a list. Ifkeyis not a list, this performs no operation.- Parameters:
key- The key of the list.elements- The elements to insert at the tail of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long listLength = client.rpushx("my_list", new String[] {"value1", "value2"}).get(); assert listLength >= 2L;
-
rpushx
java.util.concurrent.CompletableFuture<java.lang.Long> rpushx(GlideString key, GlideString[] elements)
Inserts all the specified values at the tail of the list stored atkey, only ifkeyexists and holds a list. Ifkeyis not a list, this performs no operation.- Parameters:
key- The key of the list.elements- The elements to insert at the tail of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long listLength = client.rpushx(gs("my_list"), new GlideString[] {gs("value1"), gs("value2")}).get(); assert listLength >= 2L;
-
lpushx
java.util.concurrent.CompletableFuture<java.lang.Long> lpushx(java.lang.String key, java.lang.String[] elements)Inserts all the specified values at the head of the list stored atkey, only ifkeyexists and holds a list. Ifkeyis not a list, this performs no operation.- Parameters:
key- The key of the list.elements- The elements to insert at the head of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long listLength = client.lpushx("my_list", new String[] {"value1", "value2"}).get(); assert listLength >= 2L;
-
lpushx
java.util.concurrent.CompletableFuture<java.lang.Long> lpushx(GlideString key, GlideString[] elements)
Inserts all the specified values at the head of the list stored atkey, only ifkeyexists and holds a list. Ifkeyis not a list, this performs no operation.- Parameters:
key- The key of the list.elements- The elements to insert at the head of the list stored atkey.- Returns:
- The length of the list after the push operation.
- See Also:
- valkey.io for details.
- Example:
Long listLength = client.lpushx(gs("my_list"), new GlideString[] {gs("value1"), gs("value2")}).get(); assert listLength >= 2L;
-
lmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>> lmpop(java.lang.String[] keys, ListDirection direction, long count)Pops one or more elements from the first non-empty list from the providedkeys.- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.count- The maximum number of popped elements.- Returns:
- A
Mapofkeyname mapped array of popped elements. If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush("testKey", new String[] {"one", "two", "three"}).get(); Map<String, String[]> result = client.lmpop(new String[] {"testKey"}, PopDirection.LEFT, 1L).get(); String[] resultValue = result.get("testKey"); assertArrayEquals(new String[] {"three"}, resultValue);
-
lmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>> lmpop(GlideString[] keys, ListDirection direction, long count)
Pops one or more elements from the first non-empty list from the providedkeys.- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.count- The maximum number of popped elements.- Returns:
- A
Mapofkeyname mapped array of popped elements. If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush(gs("testKey"), new GlideString[] {gs("one"), gs("two"), gs("three")}).get(); Map<GlideString, GlideString[]> result = client.lmpop(new GlideString[] {gs("testKey")}, PopDirection.LEFT, 1L).get(); GlideString[] resultValue = result.get(gs("testKey")); assertArrayEquals(new GlideString[] {gs("three")}, resultValue);
-
lmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>> lmpop(java.lang.String[] keys, ListDirection direction)Pops one element from the first non-empty list from the providedkeys.- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.- Returns:
- A
Mapofkeyname mapped array of the popped element. If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush("testKey", new String[] {"one", "two", "three"}).get(); Map<String, String[]> result = client.lmpop(new String[] {"testKey"}, PopDirection.LEFT).get(); String[] resultValue = result.get("testKey"); assertArrayEquals(new String[] {"three"}, resultValue);
-
lmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>> lmpop(GlideString[] keys, ListDirection direction)
Pops one element from the first non-empty list from the providedkeys.- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.- Returns:
- A
Mapofkeyname mapped array of the popped element. If no member could be popped, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush(gs("testKey"), new GlideString[] {gs("one"), gs("two"), gs("three")}).get(); Map<GlideString, GlideString[]> result = client.lmpop(new GlideString[] {gs("testKey")}, PopDirection.LEFT).get(); GlideString[] resultValue = result.get(gs("testKey")); assertArrayEquals(new GlideString[] {gs("three")}, resultValue);
-
blmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>> blmpop(java.lang.String[] keys, ListDirection direction, long count, double timeout)Blocks the connection until it pops one or more elements from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection, long).- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.count- The maximum number of popped elements.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A
Mapofkeyname mapped array of popped elements.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush("testKey", new String[] {"one", "two", "three"}).get(); Map<String, String[]> result = client.blmpop(new String[] {"testKey"}, PopDirection.LEFT, 1L, 0.1).get(); String[] resultValue = result.get("testKey"); assertArrayEquals(new String[] {"three"}, resultValue);
-
blmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>> blmpop(GlideString[] keys, ListDirection direction, long count, double timeout)
Blocks the connection until it pops one or more elements from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection, long).- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.count- The maximum number of popped elements.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A
Mapofkeyname mapped array of popped elements.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush(gs("testKey"), new GlideString[] {gs("one"), gs("two"), gs("three")}).get(); Map<GlideString, GlideString[]> result = client.blmpop(new GlideString[] {gs("testKey")}, PopDirection.LEFT, 1L, 0.1).get(); GlideString[] resultValue = result.get(gs("testKey")); assertArrayEquals(new GlideString[] {gs("three")}, resultValue);
-
blmpop
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String[]>> blmpop(java.lang.String[] keys, ListDirection direction, double timeout)Blocks the connection until it pops one element from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection).- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A
Mapofkeyname mapped array of the popped element.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush("testKey", new String[] {"one", "two", "three"}).get(); Map<String, String[]> result = client.blmpop(new String[] {"testKey"}, PopDirection.LEFT, 0.1).get(); String[] resultValue = result.get("testKey"); assertArrayEquals(new String[] {"three"}, resultValue);
-
blmpop
java.util.concurrent.CompletableFuture<java.util.Map<GlideString,GlideString[]>> blmpop(GlideString[] keys, ListDirection direction, double timeout)
Blocks the connection until it pops one element from the first non-empty list from the providedkeysBLMPOPis the blocking variant oflmpop(String[], ListDirection).- Parameters:
keys- An array of keys to lists.direction- The direction based on which elements are popped from - seeListDirection.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- A
Mapofkeyname mapped array of the popped element.
If no member could be popped and the timeout expired, returnsnull. - Since:
- Valkey 7.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush(gs("testKey"), new GlideString[] {gs("one"), gs("two"), gs("three")}).get(); Map<GlideString, GlideString[]> result = client.blmpop(new GlideString[] {gs("testKey")}, PopDirection.LEFT, 0.1).get(); GlideString[] resultValue = result.get(gs("testKey")); assertArrayEquals(new GlideString[] {gs("three")}, resultValue);
-
lset
java.util.concurrent.CompletableFuture<java.lang.String> lset(java.lang.String key, long index, java.lang.String element)Sets the list element atindextoelement.
The index is zero-based, so0means the first element,1the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here,-1means the last element,-2means the penultimate and so forth.- Parameters:
key- The key of the list.index- The index of the element in the list to be set.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = client.lset("testKey", 1, "two").get(); assertEquals(response, "OK");
-
lset
java.util.concurrent.CompletableFuture<java.lang.String> lset(GlideString key, long index, GlideString element)
Sets the list element atindextoelement.
The index is zero-based, so0means the first element,1the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here,-1means the last element,-2means the penultimate and so forth.- Parameters:
key- The key of the list.index- The index of the element in the list to be set.- Returns:
OK.- See Also:
- valkey.io for details.
- Example:
String response = client.lset(gs("testKey"), 1, gs("two")).get(); assertEquals(response, "OK");
-
lmove
java.util.concurrent.CompletableFuture<java.lang.String> lmove(java.lang.String source, java.lang.String destination, ListDirection wherefrom, ListDirection whereto)Atomically pops and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.- Parameters:
source- The key to the source list.destination- The key to the destination list.wherefrom- TheListDirectionthe element should be removed from.whereto- TheListDirectionthe element should be added to.- Returns:
- The popped element or
nullifsourcedoes not exist. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush("testKey1", new String[] {"two", "one"}).get(); client.lpush("testKey2", new String[] {"four", "three"}).get(); var result = client.lmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT).get(); assertEquals(result, "one"); String[] upratedArray1 = client.lrange("testKey1", 0, -1).get(); String[] upratedArray2 = client.lrange("testKey2", 0, -1).get(); assertArrayEquals(new String[] {"two"}, updatedArray1); assertArrayEquals(new String[] {"one", "three", "four"}, updatedArray2);
-
lmove
java.util.concurrent.CompletableFuture<GlideString> lmove(GlideString source, GlideString destination, ListDirection wherefrom, ListDirection whereto)
Atomically pops and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.- Parameters:
source- The key to the source list.destination- The key to the destination list.wherefrom- TheListDirectionthe element should be removed from.whereto- TheListDirectionthe element should be added to.- Returns:
- The popped element or
nullifsourcedoes not exist. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush(gs("testKey1"), new GlideString[] {gs("two"), gs("one")}).get(); client.lpush(gs("testKey2"), new GlideString[] {gs("four"), gs("three")}).get(); var result = client.lmove(gs("testKey1"), gs("testKey2"), ListDirection.LEFT, ListDirection.LEFT).get(); assertEquals(result, gs("one")); GlideString[] upratedArray1 = client.lrange(gs("testKey1"), 0, -1).get(); GlideString[] upratedArray2 = client.lrange(gs("testKey2"), 0, -1).get(); assertArrayEquals(new GlideString[] {gs("two")}, updatedArray1); assertArrayEquals(new GlideString[] {gs("one"), gs("three"), gs("four)"}, updatedArray2);
-
blmove
java.util.concurrent.CompletableFuture<java.lang.String> blmove(java.lang.String source, java.lang.String destination, ListDirection wherefrom, ListDirection whereto, double timeout)Blocks the connection until it pops atomically and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.
BLMoveis the blocking variant oflmove(String, String, ListDirection, ListDirection).- Parameters:
source- The key to the source list.destination- The key to the destination list.wherefrom- TheListDirectionthe element should be removed from.whereto- TheListDirectionthe element should be added to.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- The popped element or
nullifsourcedoes not exist or if the operation timed-out. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush("testKey1", new String[] {"two", "one"}).get(); client.lpush("testKey2", new String[] {"four", "three"}).get(); var result = client.blmove("testKey1", "testKey2", ListDirection.LEFT, ListDirection.LEFT, 0.1).get(); assertEquals(result, "one"); String[] upratedArray1 = client.lrange("testKey1", 0, -1).get(); String[] upratedArray2 = client.lrange("testKey2", 0, -1).get(); assertArrayEquals(new String[] {"two"}, updatedArray1); assertArrayEquals(new String[] {"one", "three", "four"}, updatedArray2);
-
blmove
java.util.concurrent.CompletableFuture<GlideString> blmove(GlideString source, GlideString destination, ListDirection wherefrom, ListDirection whereto, double timeout)
Blocks the connection until it pops atomically and removes the left/right-most element to the list stored atsourcedepending onwherefrom, and pushes the element at the first/last element of the list stored atdestinationdepending onwherefrom.
BLMoveis the blocking variant oflmove(String, String, ListDirection, ListDirection).- Parameters:
source- The key to the source list.destination- The key to the destination list.wherefrom- TheListDirectionthe element should be removed from.whereto- TheListDirectionthe element should be added to.timeout- The number of seconds to wait for a blocking operation to complete. A value of0will block indefinitely.- Returns:
- The popped element or
nullifsourcedoes not exist or if the operation timed-out. - Since:
- Valkey 6.2.0 and above.
- See Also:
- valkey.io for details.
- Example:
client.lpush(gs("testKey1"), new GlideString[] {gs("two"), gs("one")}).get(); client.lpush(gs("testKey2"), new GlideString[] {gs("four"), gs("three")}).get(); var result = client.blmove(gs("testKey1"), gs("testKey2"), ListDirection.LEFT, ListDirection.LEFT, 0.1).get(); assertEquals(result, gs("one")); GlideString[] upratedArray1 = client.lrange(gs("testKey1"), 0, -1).get(); GlideString[] upratedArray2 = client.lrange(gs("testKey2"), 0, -1).get(); assertArrayEquals(new GlideString[] {gs("two")}, updatedArray1); assertArrayEquals(new GlideString[] {gs("one"), gs("three"), gs("four")}, updatedArray2);
-
-