java.lang.Object
org.springframework.data.redis.connection.stream.RecordId

public class RecordId extends Object
The id of a single Record within a stream. Composed of two parts: <millisecondsTime>-<sequenceNumber>.
Since:
2.2
Author:
Christoph Strobl
See Also:
  • Method Details

    • of

      public static RecordId of(@Nullable String value)
      Obtain an instance of RecordId using the provided String formatted as <millisecondsTime>-<sequenceNumber>.
      For server auto generated entry-id on insert pass in null or *. Event better, just use autoGenerate().
      Parameters:
      value - can be null.
      Returns:
      new instance of RecordId if no autogenerated one requested.
    • of

      public static RecordId of(long millisecondsTime, long sequenceNumber)
      Create a new instance of RecordId using the provided String formatted as <millisecondsTime>-<sequenceNumber>.
      For server auto generated entry-id on insert use autoGenerate().
      Parameters:
      millisecondsTime -
      sequenceNumber -
      Returns:
      new instance of RecordId.
    • autoGenerate

      public static RecordId autoGenerate()
      Obtain the RecordId signalling the server to auto generate an entry-id on insert (XADD).
      Returns:
      RecordId instance signalling shouldBeAutoGenerated().
    • getTimestamp

      @Nullable public Long getTimestamp()
      Get the entry-id millisecondsTime part or null if it shouldBeAutoGenerated().
      Returns:
      millisecondsTime of the entry-id. Can be null.
    • getSequence

      @Nullable public Long getSequence()
      Get the entry-id sequenceNumber part or null if it shouldBeAutoGenerated().
      Returns:
      sequenceNumber of the entry-id. Can be null.
    • shouldBeAutoGenerated

      public boolean shouldBeAutoGenerated()
      Returns:
      true if a new entry-id shall be generated on server side when calling XADD.
    • getValue

      public String getValue()
      Returns:
      get the string representation of the entry-id in <millisecondsTime>-<sequenceNumber> format or * if it shouldBeAutoGenerated(). Never null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object