Class SetArgs

  • All Implemented Interfaces:
    CompositeArgument

    public class SetArgs
    extends Object
    implements CompositeArgument
    Argument list builder for the Redis SET command starting from Redis 2.6.12. Static import the methods from SetArgs.Builder and chain the method calls: ex(10).nx().

    SetArgs is a mutable object and instances should be used only once to avoid shared mutable state.

    Author:
    Will Glozer, Vincent Rischmann, Mark Paluch
    • Constructor Detail

      • SetArgs

        public SetArgs()
    • Method Detail

      • ex

        public SetArgs ex​(long timeout)
        Set the specified expire time, in seconds.
        Parameters:
        timeout - expire time in seconds.
        Returns:
        this SetArgs.
      • ex

        public SetArgs ex​(Duration timeout)
        Set the specified expire time, in seconds.
        Parameters:
        timeout - expire time in seconds.
        Returns:
        this SetArgs.
        Since:
        6.1
      • exAt

        public SetArgs exAt​(long timestamp)
        Set the specified expire at time using a posix timestamp.
        Parameters:
        timestamp - the timestamp type: posix time in seconds.
        Returns:
        this SetArgs.
        Since:
        6.1
      • exAt

        public SetArgs exAt​(Date timestamp)
        Set the specified expire at time using a posix timestamp.
        Parameters:
        timestamp - the timestamp type: posix time in seconds.
        Returns:
        this SetArgs.
        Since:
        6.1
      • exAt

        public SetArgs exAt​(Instant timestamp)
        Set the specified expire at time using a posix timestamp.
        Parameters:
        timestamp - the timestamp type: posix time in seconds.
        Returns:
        this SetArgs.
        Since:
        6.1
      • px

        public SetArgs px​(long timeout)
        Set the specified expire time, in milliseconds.
        Parameters:
        timeout - expire time in milliseconds.
        Returns:
        this SetArgs.
      • px

        public SetArgs px​(Duration timeout)
        Set the specified expire time, in milliseconds.
        Parameters:
        timeout - expire time in milliseconds.
        Returns:
        this SetArgs.
      • pxAt

        public SetArgs pxAt​(long timestamp)
        Set the specified expire at time using a posix timestamp.
        Parameters:
        timestamp - the timestamp type: posix time in milliseconds.
        Returns:
        this SetArgs.
        Since:
        6.1
      • pxAt

        public SetArgs pxAt​(Date timestamp)
        Set the specified expire at time using a posix timestamp.
        Parameters:
        timestamp - the timestamp type: posix time in milliseconds.
        Returns:
        this SetArgs.
        Since:
        6.1
      • pxAt

        public SetArgs pxAt​(Instant timestamp)
        Set the specified expire at time using a posix timestamp.
        Parameters:
        timestamp - the timestamp type: posix time in milliseconds.
        Returns:
        this SetArgs.
        Since:
        6.1
      • nx

        public SetArgs nx()
        Only set the key if it does not already exist.
        Returns:
        this SetArgs.
      • keepttl

        public SetArgs keepttl()
        Set the value and retain the existing TTL.
        Returns:
        this SetArgs.
        Since:
        5.3
      • xx

        public SetArgs xx()
        Only set the key if it already exists.
        Returns:
        this SetArgs.
      • build

        public <K,​V> void build​(CommandArgs<K,​V> args)
        Description copied from interface: CompositeArgument
        Build command arguments and contribute arguments to CommandArgs.

        Implementing classes are required to implement this method. Depending on the command nature and configured arguments, this method may contribute arguments but is not required to add arguments if none are specified.

        Specified by:
        build in interface CompositeArgument
        Type Parameters:
        K - Key type.
        V - Value type.
        Parameters:
        args - the command arguments, must not be null.