forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Lpush, Lpop, LpopCount, Lrange, Llen, Ltrim and Lrem Commands. …
…(List Commands)
- Loading branch information
1 parent
98b1ed7
commit 5cc6df4
Showing
11 changed files
with
756 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
java/client/src/main/java/glide/api/commands/ListCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.commands; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* List Commands interface. | ||
* | ||
* @see <a href="https://redis.io/commands/?group=list">List Commands</a> | ||
*/ | ||
public interface ListCommands { | ||
/** | ||
* Inserts all the specified values at the head of the list stored at <code>key</code>. <code> | ||
* elements</code> are inserted one after the other to the head of the list, from the leftmost | ||
* element to the rightmost element. If <code>key</code> does not exist, it is created as an empty | ||
* list before performing the push operations. | ||
* | ||
* @see <a href="https://redis.io/commands/lpush/">redis.io</a> for details. | ||
* @param key The key of the list. | ||
* @param elements The elements to insert at the head of the list stored at <code>key</code>. | ||
* @return The length of the list after the push operations.<br> | ||
* If <code>key</code> holds a value that is not a list, an error is raised.<br> | ||
*/ | ||
CompletableFuture<Long> lpush(String key, String[] elements); | ||
|
||
/** | ||
* Removes and returns the first elements of the list stored at <code>key</code>. The command pops | ||
* a single element from the beginning of the list. | ||
* | ||
* @see <a href="https://redis.io/commands/lpop/">redis.io</a> for details. | ||
* @param key The key of the list. | ||
* @return The value of the first element. <br> | ||
* If <code>key</code> does not exist null will be returned. <br> | ||
* If <code>key</code> holds a value that is not a list, an error is raised. <br> | ||
*/ | ||
CompletableFuture<String> lpop(String key); | ||
|
||
/** | ||
* Removes and returns up to <code>count</code> elements of the list stored at <code>key</code>, | ||
* depending on the list's length. | ||
* | ||
* @see <a href="https://redis.io/commands/lpop/">redis.io</a> for details. | ||
* @param key The key of the list. | ||
* @param count The count of the elements to pop from the list. | ||
* @return An array of the popped elements will be returned depending on the list's length.<br> | ||
* If <code>key</code> does not exist null will be returned.<br> | ||
* If <code>key</code> holds a value that is not a list, an error is raised.<br> | ||
*/ | ||
CompletableFuture<String[]> lpopCount(String key, long count); | ||
|
||
/** | ||
* Returns the specified elements of the list stored at <code>key</code>. The offsets <code>start | ||
* </code> and <code>end</code> are 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. | ||
* | ||
* @see <a href="https://redis.io/commands/lrange/">redis.io</a> for details. | ||
* @param key The key of the list. | ||
* @param start The starting point of the range. | ||
* @param end The end of the range. | ||
* @return Array of elements in the specified range.<br> | ||
* If <code>start</code> exceeds the end of the list, or if <code>start</code> is greater than | ||
* <code>end</code>, an empty array will be returned.<br> | ||
* If <code>end</code> exceeds the actual end of the list, the range will stop at the actual | ||
* end of the list.<br> | ||
* If <code>key</code> does not exist an empty array will be returned.<br> | ||
* If <code>key</code> holds a value that is not a list, an error is raised.<br> | ||
*/ | ||
CompletableFuture<String[]> lrange(String key, long start, long end); | ||
|
||
/** | ||
* Returns the length of the list stored at <code>key</code>. | ||
* | ||
* @see <a href="https://redis.io/commands/llen/">redis.io</a> for details. | ||
* @param key The key of the list. | ||
* @return The length of the list at <code>key</code>. <br> | ||
* If <code>key</code> does not exist, it is interpreted as an empty list and 0 is returned. | ||
* <br> | ||
* If <code>key</code> holds a value that is not a list, an error is raised. <br> | ||
*/ | ||
CompletableFuture<Long> llen(String key); | ||
|
||
/** | ||
* Trim an existing list so that it will contain only the specified range of elements specified. | ||
* The offsets <code>start</code> and <code>end</code> are 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. | ||
* | ||
* @see <a href="https://redis.io/commands/ltrim/">redis.io</a> for details. | ||
* @param key The key of the list. | ||
* @param start The starting point of the range. | ||
* @param end The end of the range. | ||
* @return Always <code>OK</code>. <br> | ||
* If <code>start</code> exceeds the end of the list, or if <code>start</code> is greater than | ||
* <code>end</code>, the result will be an empty list (which causes key to be removed). <br> | ||
* If <code>end</code> exceeds the actual end of the list, it will be treated like the last | ||
* element of the list. <br> | ||
* If <code>key</code> does not exist the command will be ignored. <br> | ||
* If <code>key</code> holds a value that is not a list, an error is raised. <br> | ||
*/ | ||
CompletableFuture<String> ltrim(String key, long start, long end); | ||
|
||
/** | ||
* Removes the first <code>count</code> occurrences of elements equal to <code>element</code> from | ||
* the list stored at <code>key</code>.<br> | ||
* If <code>count</code> is positive: Removes elements equal to <code>element</code> moving from | ||
* head to tail.<br> | ||
* If <code>count</code> is negative: Removes elements equal to <code>element</code> moving from | ||
* tail to head.<br> | ||
* If <code>count</code> is 0 or <code>count</code> is greater than the occurrences of elements | ||
* equal to <code>element</code>: Removes all elements equal to <code>element</code>.<br> | ||
* | ||
* @see <a href="https://redis.io/commands/lrem/">redis.io</a> for details. | ||
* @param key The key of the list. | ||
* @param count The count of the occurrences of elements equal to <code>element</code> to remove. | ||
* @param element The element to remove from the list. | ||
* @return The number of the removed elements.<br> | ||
* If <code>key</code> does not exist, 0 is returned.<br> | ||
* If <code>key</code> holds a value that is not a list, an error is raised.<br> | ||
*/ | ||
CompletableFuture<Long> lrem(String key, long count, String element); | ||
} |
Oops, something went wrong.