Package glide.api.models.commands
Enum FieldConditionalChange
- java.lang.Object
-
- java.lang.Enum<FieldConditionalChange>
-
- glide.api.models.commands.FieldConditionalChange
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<FieldConditionalChange>
public enum FieldConditionalChange extends java.lang.Enum<FieldConditionalChange>
Field-specific conditional change options for HSETEX command.These options control when hash fields should be set based on their current existence state. They provide fine-grained control over field creation and updates in hash field expiration commands.
- Since:
- Valkey 9.0.0
- See Also:
- HSETEX Command Documentation
- Example:
// Only set fields if all of them already exist FieldConditionalChange condition = FieldConditionalChange.ONLY_IF_ALL_EXIST; // Only set fields if none of them already exist FieldConditionalChange condition = FieldConditionalChange.ONLY_IF_NONE_EXIST;
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ONLY_IF_ALL_EXISTOnly set fields if all of them already exist.ONLY_IF_NONE_EXISTOnly set fields if none of them already exist.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetValkeyApi()The Valkey API string representation of this conditional change option.static FieldConditionalChangevalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static FieldConditionalChange[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
ONLY_IF_ALL_EXIST
public static final FieldConditionalChange ONLY_IF_ALL_EXIST
Only set fields if all of them already exist. Equivalent toFXXin the Valkey API.When this option is used, the HSETEX command will only update existing fields and will not create new fields. If any of the specified fields do not exist, the entire operation fails.
- Example:
// This will only succeed if both "field1" and "field2" already exist in the hash HSetExOptions options = HSetExOptions.builder() .fieldConditionalChange(FieldConditionalChange.ONLY_IF_ALL_EXIST) .expiry(ExpirySet.Seconds(60L)) .build();
-
ONLY_IF_NONE_EXIST
public static final FieldConditionalChange ONLY_IF_NONE_EXIST
Only set fields if none of them already exist. Equivalent toFNXin the Valkey API.When this option is used, the HSETEX command will only create new fields and will not update existing fields. If any of the specified fields already exist, the entire operation fails.
- Example:
// This will only succeed if neither "field1" nor "field2" exist in the hash HSetExOptions options = HSetExOptions.builder() .fieldConditionalChange(FieldConditionalChange.ONLY_IF_NONE_EXIST) .expiry(ExpirySet.Seconds(60L)) .build();
-
-
Method Detail
-
values
public static FieldConditionalChange[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (FieldConditionalChange c : FieldConditionalChange.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static FieldConditionalChange valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
getValkeyApi
public java.lang.String getValkeyApi()
The Valkey API string representation of this conditional change option.
-
-