-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add HGETDEL, HGETEX and HSETEX hash commands #3204
base: main
Are you sure you want to change the base?
Conversation
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.
PR Overview
This PR adds support for three new hash commands—HGETDEL, HGETEX, and HSETEX—to enable atomic operations combining field updates with expiry management. Key changes include:
- Introducing new argument builder classes (HGetExArgs and HSetExArgs) for handling expiration and persistence options.
- Extending synchronous, asynchronous, and reactive APIs with new methods and updating the command builder accordingly.
- Adding new integration and unit tests to validate the behavior of the new commands.
Reviewed Changes
File | Description |
---|---|
src/main/java/io/lettuce/core/HGetExArgs.java | New builder class for HGETEX arguments with expiry and persistence. |
src/main/java/io/lettuce/core/api/async/RedisHashAsyncCommands.java | Added HGETDEL, HGETEX, and HSETEX method signatures for async commands. |
src/main/templates/io/lettuce/core/api/RedisHashCommands.java | Extended synchronous command template with new hash commands. |
src/main/java/io/lettuce/core/api/reactive/RedisHashReactiveCommands.java | Added reactive APIs for new commands. |
src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionHashCommands.java | Extended cluster sync API with new hash commands. |
src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionHashAsyncCommands.java | Extended cluster async API with new hash commands. |
src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java | Introduced new integration tests covering the new commands. |
src/main/java/io/lettuce/core/RedisCommandBuilder.java | Updated command builder to support HSETEX and HGETEX construction. |
src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java | Updated reactive command implementations for new commands. |
src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java | Updated async command implementations for new commands. |
src/main/java/io/lettuce/core/protocol/CommandKeyword.java | Minor update to include additional keywords. |
src/main/java/io/lettuce/core/protocol/CommandType.java | Extended CommandType enum with HGETDEL, HSETEX, and HGETEX. |
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java
Outdated
Show resolved
Hide resolved
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.
LGTM generally, only a few things you could address
* {@link HGetExArgs} is a mutable object and instances should be used only once to avoid shared mutable state. | ||
* | ||
* @author Ivo Gaydajiev | ||
* @since 6.7.0 |
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.
can we change this to 6.6 (everywhere)
6.7 is not yet planned and we need to release this soon
also we usually do not put patch release, because no new functionality is added in patch releases
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.
will do. 6.7 is the current snapshot version in the pom. So I thought this would be the next release version.
|
||
LettuceAssert.notNull(timeout, "Timeout must not be null"); | ||
|
||
this.ex = timeout.toMillis() / 1000; |
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.
Using getSeconds() I think is the same
|
||
LettuceAssert.notNull(timestamp, "Timestamp must not be null"); | ||
|
||
return exAt(timestamp.toEpochMilli() / 1000); |
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.
getEpochSecond() should be the same I think
* @return new {@link HGetExArgs} with {@literal EX} enabled. | ||
* @see HGetExArgs#ex(long) | ||
*/ | ||
public static HGetExArgs ex(long timeout) { |
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.
IMHO we should only use Duration
and Instant
for newly introduced APIs.
The long
and Date
approaches are no longer the best way to handle timeframes.
This goes for all classes and all methods, not only this one.
- @SInCE 6.7.0 -> 6.6 - Remove long/Date methods for settin timestamp
This PR adds support for three new hash commands: HGETDEL, HGETEX and HSETEX. These commands enable user to do multiple operations in one step atomically e.g. set a hash field and update its TTL with a single command.
Make sure that:
mvn formatter:format
target. Don’t submit any formatting related changes.Closes #3195