Module lettuce.core

Class SetArgs

java.lang.Object
io.lettuce.core.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
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  SetArgs.Builder
    Builder entry points for SetArgs.
  • Constructor Summary

    Constructors
    Constructor Description
    SetArgs()  
  • Method Summary

    Modifier and Type Method Description
    <K,​ V> void build​(CommandArgs<K,​V> args)
    Build command arguments and contribute arguments to CommandArgs.
    SetArgs ex​(long timeout)
    Set the specified expire time, in seconds.
    SetArgs ex​(Duration timeout)
    Set the specified expire time, in seconds.
    SetArgs exAt​(long timestamp)
    Set the specified expire at time using a posix timestamp.
    SetArgs exAt​(Instant timestamp)
    Set the specified expire at time using a posix timestamp.
    SetArgs exAt​(Date timestamp)
    Set the specified expire at time using a posix timestamp.
    SetArgs keepttl()
    Set the value and retain the existing TTL.
    SetArgs nx()
    Only set the key if it does not already exist.
    SetArgs px​(long timeout)
    Set the specified expire time, in milliseconds.
    SetArgs px​(Duration timeout)
    Set the specified expire time, in milliseconds.
    SetArgs pxAt​(long timestamp)
    Set the specified expire at time using a posix timestamp.
    SetArgs pxAt​(Instant timestamp)
    Set the specified expire at time using a posix timestamp.
    SetArgs pxAt​(Date timestamp)
    Set the specified expire at time using a posix timestamp.
    SetArgs xx()
    Only set the key if it already exists.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SetArgs

      public SetArgs()
  • Method Details

    • 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.