-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[DRAFT] Support sub second timeout for BRPOP & BLPOP via RedisListCommands. #2127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
78013be
Support sub second timeout for BRPOP & BLPOP via RedisListCommands.
ihaohong e5fca25
asset
ihaohong 1894a9f
millseconds
ihaohong c2420b4
fix
ihaohong 0f08542
fix
ihaohong 4e0ee3a
fix
ihaohong 7904495
fix
ihaohong 90ba014
fix
ihaohong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
package org.springframework.data.redis.connection; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.springframework.lang.Nullable; | ||
import org.springframework.util.CollectionUtils; | ||
|
@@ -27,6 +28,7 @@ | |
* @author Christoph Strobl | ||
* @author Mark Paluch | ||
* @author dengliming | ||
* @author ihaohong | ||
*/ | ||
public interface RedisListCommands { | ||
|
||
|
@@ -314,6 +316,21 @@ default Long lPos(byte[] key, byte[] element) { | |
@Nullable | ||
List<byte[]> bLPop(int timeout, byte[]... keys); | ||
|
||
/** | ||
* Removes and returns first element from lists stored at {@code keys}. <br> | ||
* <b>Blocks connection</b> until element available or {@code timeout} reached. | ||
* | ||
* @param timeout seconds to block. | ||
* @param unit time unit for timeout | ||
* @param keys must not be {@literal null}. | ||
* @return empty {@link List} when no element could be popped and the timeout was reached. {@literal null} when used | ||
* in pipeline / transaction. | ||
* @see <a href="https://redis.io/commands/blpop">Redis Documentation: BLPOP</a> | ||
* @see #lPop(byte[]) | ||
*/ | ||
@Nullable | ||
List<byte[]> bLPop(int timeout, TimeUnit unit, byte[]... keys); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
|
||
/** | ||
* Removes and returns last element from lists stored at {@code keys}. <br> | ||
* <b>Blocks connection</b> until element available or {@code timeout} reached. | ||
|
@@ -328,6 +345,21 @@ default Long lPos(byte[] key, byte[] element) { | |
@Nullable | ||
List<byte[]> bRPop(int timeout, byte[]... keys); | ||
|
||
/** | ||
* Removes and returns last element from lists stored at {@code keys}. <br> | ||
* <b>Blocks connection</b> until element available or {@code timeout} reached. | ||
* | ||
* @param timeout seconds to block. | ||
* @param unit time unit for timeout | ||
* @param keys must not be {@literal null}. | ||
* @return empty {@link List} when no element could be popped and the timeout was reached. {@literal null} when used | ||
* in pipeline / transaction. | ||
* @see <a href="https://redis.io/commands/brpop">Redis Documentation: BRPOP</a> | ||
* @see #rPop(byte[]) | ||
*/ | ||
@Nullable | ||
List<byte[]> bRPop(int timeout, TimeUnit unit, byte[]... keys); | ||
|
||
/** | ||
* Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value. | ||
* | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd like to keep
Duration
as that is the more expressive API.TimeUnit
and timeout always require a tuple.