JAVA: Valkey 9 new commands HASH items expiration#4556
Merged
Conversation
e64d86b to
6197a11
Compare
4 tasks
edlng
reviewed
Aug 11, 2025
Collaborator
edlng
left a comment
There was a problem hiding this comment.
As we discussed in #4554 (comment), let's wait until RC is released and rerun CI to test before merging
java/client/src/main/java/glide/api/commands/HashBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/HashBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/HashFieldExpirationOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/HashFieldExpirationOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/HashFieldExpirationOptions.java
Outdated
Show resolved
Hide resolved
edlng
reviewed
Aug 11, 2025
java/client/src/main/java/glide/api/commands/HashBaseCommands.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/HashBaseCommands.java
Outdated
Show resolved
Hide resolved
alexr-bq
reviewed
Aug 11, 2025
java/client/src/test/java/glide/api/commands/HashFieldExpirationCommandsTest.java
Outdated
Show resolved
Hide resolved
6197a11 to
cc4c942
Compare
Yury-Fridlyand
previously requested changes
Aug 12, 2025
Yury-Fridlyand
left a comment
There was a problem hiding this comment.
LGTM, but
We can't merge until test. We can't test without valkey 9 (or 9 RC) in CI.
CI updates should be merged in another PR ahead of this one.
Collaborator
|
You can configure CI to run on Valkey 9 like this: |
alexr-bq
approved these changes
Aug 26, 2025
java/client/src/main/java/glide/api/models/commands/HGetExOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/HashFieldExpirationConditionOptions.java
Outdated
Show resolved
Hide resolved
Yury-Fridlyand
approved these changes
Aug 27, 2025
java/client/src/main/java/glide/api/models/commands/HGetExExpiry.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/HGetExOptions.java
Outdated
Show resolved
Hide resolved
java/client/src/main/java/glide/api/models/commands/HSetExOptions.java
Outdated
Show resolved
Hide resolved
Add support for HSETEX command in Java client. - Add HashFieldExpirationOptions class with builder pattern for command options - Implement hash field expiration methods in HashBaseCommands interface - Add unit tests for all new commands and options - Add integration tests to verify command functionality - Update protobuf definitions and Rust request types - Add batch operation support for all new commands This implementation provides full support for hash field expiration functionality. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Add support for the HGETEX command which retrieves hash field values and optionally sets their expiration or removes it. Changes: - Add HGetex request type to protobuf and Rust core - Implement hgetex() methods in BaseClient and HashBaseCommands - Add batch support for hgetex operations - Extend HashFieldExpirationOptions with Persist() option - Add comprehensive integration tests covering: * Basic functionality with expiry setting * PERSIST option to remove field expiration * Binary parameter support (GlideString) * Batch operation support The implementation supports both String and GlideString parameters and includes proper validation for the PERSIST option which cannot be combined with conditional options. Requires Valkey 9.0.0 or higher. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Add support for the HEXPIRE command which sets expiration time in seconds for specified fields in a hash. This command is available in Valkey 9.0+. Changes: - Add HExpire (619) to protobuf command request types - Implement hexpire() methods in BaseClient and HashBaseCommands - Support both String and GlideString parameter variants - Add batch operation support in BaseBatch - Include test coverage for: * Basic functionality with multiple fields * Conditional expiration options (NX, XX, GT, LT) * Immediate deletion with 0 seconds * Binary parameter support * Batch operation functionality The implementation follows existing patterns and maintains compatibility with the HashFieldExpirationOptions for conditional expiration logic. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Add support for the HPERSIST command which removes expiration time from hash fields, making them persistent. Changes: - Add HPersist request type to protobuf and core request handling - Implement hpersist() methods in BaseClient and HashBaseCommands - Add batch support for HPERSIST operations - Support both String and GlideString parameter types - Add test coverage including edge cases and binary support Requires Valkey 9.0.0 or higher. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
…conds - Add HPEXPIRE request type (621) to protobuf and Rust request handling - Implement HPEXPIRE in Java BaseClient and HashBaseCommands interface - Add batch support for HPEXPIRE operations - Include comprehensive integration tests covering: * Basic functionality with multiple fields * Conditional expiration options (NX, XX, GT, LT) * Immediate deletion with 0ms expiration * Binary parameter support with GlideString * Batch operation functionality This complements the existing HEXPIRE command by providing millisecond precision for hash field expiration, following Valkey 9.0+ specifications. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Add support for the HEXPIREAT command which sets expiration time for hash fields using absolute Unix timestamps in seconds. This complements the existing HEXPIRE command by allowing timestamp-based expiration. Changes: - Add HExpireAt (622) request type to protobuf and Rust core - Implement hexpireat() methods in BaseClient and HashBaseCommands - Add batch support for hexpireat operations - Support both String and GlideString parameter variants - Include test coverage for all scenarios Features: - Sets expiration using Unix timestamp in seconds - Supports HashFieldExpirationOptions for conditional expiration - Handles immediate deletion for past timestamps - Creates hash if it doesn't exist - Returns Boolean array indicating success per field Requires Valkey 9.0.0 or higher. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Add support for HPEXPIREAT command which sets expiration time for hash fields using Unix timestamp in milliseconds, complementing the existing HEXPIREAT command that uses seconds. Changes: - Add HPExpireAt (623) request type to protobuf and Rust core - Implement hpexpireat() methods in BaseClient and BaseBatch classes - Add interface documentation with examples - Support both String and GlideString parameter variants - Include full integration test coverage for all scenarios The implementation follows the same patterns as existing hash expiration commands and requires Valkey 9.0.0 or higher. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Add support for the HTTL command to query remaining time-to-live of hash fields in seconds. This command is available in Valkey 9.0+. Changes: - Add HTtl request type (624) to protobuf and core request handling - Implement httl() methods in BaseClient and BaseBatch for both String and GlideString parameter types - Add comprehensive test coverage including basic functionality, expired fields, mixed field scenarios, and batch operations - Support for non-existent keys and fields with proper return codes (-1 for no expiration, -2 for non-existent fields) The implementation follows existing patterns for hash field expiration commands and maintains consistency with the codebase architecture. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
…IME, HPEXPIRETIME) Add support for Valkey 9.0+ hash field expiration query commands: - HPTTL: Get remaining TTL of hash fields in milliseconds - HEXPIRETIME: Get absolute expiration timestamp of hash fields in seconds - HPEXPIRETIME: Get absolute expiration timestamp of hash fields in milliseconds Changes include: * Add new RequestType enums (HPTtl=625, HExpireTime=626, HPExpireTime=627) * Implement client methods in BaseClient with String and GlideString support * Add comprehensive interface definitions in HashBaseCommands * Support batch operations in BaseBatch * Add extensive integration tests covering: - Basic functionality with mixed field states - Non-existent keys and expired fields - Binary parameter support - Batch operation testing All commands return Long[] arrays with standard Redis semantics: - Positive values: TTL/timestamp for fields with expiration - -1: Field exists but has no expiration - -2: Field does not exist Requires Valkey 9.0.0 or higher. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
- Rename HSetex/HGetex to HSetEx/HGetEx for consistent PascalCase naming - Change return types from Boolean[] to Long[] for hash expiration commands to match Valkey server response format: * 1: expiration successfully set/removed * 0: condition not met * -1: field exists but has no expiration (hpersist) * -2: field/key does not exist * 2: called with 0 seconds/milliseconds - Update documentation and examples to reflect new return value semantics - Fix command string casing in request_type.rs (HSetEx/HGetEx instead of HSETEX/HGETEX) - Add FIELDS_VALKEY_API constant for consistent "FIELDS" keyword usage - Update integration tests to verify correct return values and TTL behavior - Rename test file from HashFieldExpirationCommandsTest to HashFieldExpirationOptionsCommandsTest - Use ExpireOptions enum instead of custom ExpirationCondition enum for consistency Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
…tations - Fix HSETEX/HGETEX command names in request_type.rs (uppercase) - Use FIELDS_VALKEY_API constant in Java batch operations - Correct HSETEX return value expectations in tests (returns 1 on success) - Update conditional options to use FNX/FXX instead of NX/XX - Fix TTL assertions to match actual expiration times - Add proper type casting for batch operation results Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
…fic options classes - Replace monolithic HashFieldExpirationOptions with focused classes: * HSetExOptions for HSETEX command with field conditionals and expiry * HGetExOptions for HGETEX command with PERSIST support * HExpireOptions, HPExpireOptions for HEXPIRE/HPEXPIRE commands * HExpireAtOptions, HPExpireAtOptions for HEXPIREAT/HPEXPIREAT commands - Add supporting classes: * ExpirySet for standard expiry configurations (EX/PX/EXAT/PXAT/KEEPTTL) * HGetExExpiry for HGETEX-specific expiry (supports PERSIST, excludes KEEPTTL) * FieldConditionalChange for FXX/FNX field existence conditions - Make options parameters nullable for better usability - Update method signatures across BaseClient, HashBaseCommands, and BaseBatch - Enhance JavaDoc with improved examples and clearer parameter descriptions - Improve compile-time safety by preventing invalid option combinations This refactor provides better type safety, clearer APIs, and prevents runtime errors from incompatible option combinations between different hash field expiration commands. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add Hash Field Expiration Commands Support for Java Client
Summary
This PR implements comprehensive support for hash field expiration commands in the Java client, adding new commands that enable fine-grained TTL management for individual hash fields. These commands are available in Valkey 9.0+ and provide powerful capabilities for managing field-level expiration in hash data structures.
New Commands Added
Core Commands
Key Features
Flexible Expiration Options
Advanced Conditional Logic
Implementation Details
Core Infrastructure
HashFieldExpirationOptionsclass with builder pattern for flexible option configurationClient Integration
BaseClientwith both String and GlideString overloadsBaseBatchwith generic type safetyError Handling
Testing Coverage
Unit Tests
HashFieldExpirationOptionsTest- 15+ test cases covering all option combinationsHashFieldExpirationCommandsTest- Validation logic and edge casesBatchTests- Batch operation functionalityGlideClientTest- Client method integrationIntegration Tests
Issue link
This Pull Request is linked to issue (URL): #4496
Checklist
Before submitting the PR make sure the following are checked: