Package glide.api.models.commands
Class HSetExOptions
- java.lang.Object
-
- glide.api.models.commands.HSetExOptions
-
public final class HSetExOptions extends java.lang.ObjectOptional arguments for theHSETEXcommand.HSETEX sets hash fields with expiration times and supports:
- Field conditional changes (FNX/FXX) - control when fields are set based on existence
- Standard expiry options (EX/PX/EXAT/PXAT/KEEPTTL) - set expiration times
This class provides compile-time safety by only allowing parameter combinations that are valid for the HSETEX command. It excludes options like PERSIST (which is only for HGETEX) and expiration conditions (which are only for HEXPIRE-family commands).
All instances of this class are immutable and thread-safe after construction.
- Since:
- Valkey 9.0.0
- See Also:
- HSETEX Command Documentation,
FieldConditionalChange,ExpirySet - Example:
// Set fields only if none exist, with 60 second expiration HSetExOptions options = HSetExOptions.builder() .onlyIfNoneExist() .expiry(ExpirySet.Seconds(60L)) .build(); Map<String, String> fieldValueMap = Map.of("field1", "value1", "field2", "value2"); Long result = client.hsetex("myHash", fieldValueMap, options).get(); // Set fields only if all exist, keeping existing expiration HSetExOptions options2 = HSetExOptions.builder() .onlyIfAllExist() .expiry(ExpirySet.KeepExisting()) .build(); // Set fields with Unix timestamp expiration HSetExOptions options3 = HSetExOptions.builder() .expiry(ExpirySet.UnixSeconds(1640995200L)) .build();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHSetExOptions.HSetExOptionsBuilderBuilder class forHSetExOptions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HSetExOptions.HSetExOptionsBuilderbuilder()booleanequals(java.lang.Object o)inthashCode()java.lang.String[]toArgs()Converts options into command arguments for the HSETEX command.java.lang.StringtoString()
-
-
-
Method Detail
-
toArgs
public java.lang.String[] toArgs()
Converts options into command arguments for the HSETEX command.This method validates that the expiry options are compatible with HSETEX and generates the appropriate command arguments in the correct order.
The argument order follows the HSETEX command specification:
- Field conditional change (FNX/FXX) if specified
- Expiry options (EX/PX/EXAT/PXAT/KEEPTTL) if specified
- Returns:
- String[] containing the command arguments for these options
- Throws:
java.lang.IllegalArgumentException- if expiry options are not compatible with HSETEX- Example:
HSetExOptions options = HSetExOptions.builder() .onlyIfNoneExist() .expiry(ExpirySet.Seconds(60L)) .build(); String[] args = options.toArgs(); // Returns ["FNX", "EX", "60"]
-
builder
public static HSetExOptions.HSetExOptionsBuilder builder()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-