Record Class MetadataAwareValue<V>

java.lang.Object
java.lang.Record
com.loomcache.server.datastructures.mapstore.MetadataAwareValue<V>
Type Parameters:
V - value type
Record Components:
value - stored value
expiryEpochMillis - absolute expiration time, or 0 for no expiry

public record MetadataAwareValue<V>(V value, long expiryEpochMillis) extends Record
Value carrier used by metadata-aware map stores.

The expiry timestamp is absolute epoch milliseconds so a value persisted by one map instance can be loaded by a later instance without relying on the previous process' monotonic clock.

  • Field Details

  • Constructor Details

    • MetadataAwareValue

      public MetadataAwareValue(V value, long expiryEpochMillis)
      Creates an instance of a MetadataAwareValue record class.
      Parameters:
      value - the value for the value record component
      expiryEpochMillis - the value for the expiryEpochMillis record component
  • Method Details

    • neverExpires

      public static <V> MetadataAwareValue<V> neverExpires(V value)
    • expiringAt

      public static <V> MetadataAwareValue<V> expiringAt(V value, Instant expiry)
    • expiringAtEpochMillis

      public static <V> MetadataAwareValue<V> expiringAtEpochMillis(V value, long expiryEpochMillis)
    • hasExpiry

      public boolean hasExpiry()
    • isExpired

      public boolean isExpired(long nowEpochMillis)
    • toExpiryNanoTime

      public @Nullable Long toExpiryNanoTime(long nowEpochMillis, long nowNanoTime)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • value

      public V value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • expiryEpochMillis

      public long expiryEpochMillis()
      Returns the value of the expiryEpochMillis record component.
      Returns:
      the value of the expiryEpochMillis record component