Class SetOptions.SetOptionsBuilder

  • Enclosing class:
    SetOptions

    public static class SetOptions.SetOptionsBuilder
    extends java.lang.Object
    Builder class for SetOptions.

    Provides methods to set conditions under which a value should be set.

    Note: Calling any of these methods will override the existing values of conditionalSet and comparisonValue, if they are already set.

    • Method Detail

      • conditionalSetOnlyIfEqualTo

        public SetOptions.SetOptionsBuilder conditionalSetOnlyIfEqualTo​(@NonNull
                                                                        @NonNull java.lang.String value)
        Sets the condition to SetOptions.ConditionalSet.ONLY_IF_EQUAL for setting the value. The key will be set if the provided comparison value matches the existing value.

        This method overrides any previously set conditionalSet and comparisonValue.

        Parameters:
        value - the value to compare
        Returns:
        this builder instance
        Since:
        Valkey 8.1 and above.
      • conditionalSetOnlyIfEqualTo

        public SetOptions.SetOptionsBuilder conditionalSetOnlyIfEqualTo​(@NonNull
                                                                        @NonNull GlideString value)
        Sets the condition to SetOptions.ConditionalSet.ONLY_IF_EQUAL for setting the value. The key will be set if the provided comparison value matches the existing value.

        This method overrides any previously set conditionalSet and comparisonValue.

        Parameters:
        value - the value to compare
        Returns:
        this builder instance
        Since:
        Valkey 8.1 and above.
      • conditionalSet

        public SetOptions.SetOptionsBuilder conditionalSet​(SetOptions.ConditionalSet conditionalSet)
        If conditionalSet is not set the value will be set regardless of prior value existence. If value isn't set because of the condition, command will return null.
        Returns:
        this.
      • returnOldValue

        public SetOptions.SetOptionsBuilder returnOldValue​(boolean returnOldValue)
        Set command to return the old string stored at key, or null if key did not exist. An error is returned and SET aborted if the value stored at key is not a string. Equivalent to GET in the Valkey API.
        Returns:
        this.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object