Enum 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_EXIST
      Only set fields if all of them already exist.
      ONLY_IF_NONE_EXIST
      Only 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.String getValkeyApi()
      The Valkey API string representation of this conditional change option.
      static FieldConditionalChange valueOf​(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.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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 to FXX in 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 to FNX in 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 name
        java.lang.NullPointerException - if the argument is null
      • getValkeyApi

        public java.lang.String getValkeyApi()
        The Valkey API string representation of this conditional change option.