Record Class RetentionPolicy.SizeBased

java.lang.Object
java.lang.Record
com.loomcache.server.journal.RetentionPolicy.SizeBased
Record Components:
maxEntries - Maximum number of entries to retain
All Implemented Interfaces:
RetentionPolicy
Enclosing interface:
RetentionPolicy

public static record RetentionPolicy.SizeBased(long maxEntries) extends Record implements RetentionPolicy
Size-based retention policy.

Keeps up to maxEntries most recent entries.

Since:
1.0
  • Constructor Details

    • SizeBased

      public SizeBased(long maxEntries)
      Creates an instance of a SizeBased record class.
      Parameters:
      maxEntries - the value for the maxEntries record component
  • Method Details

    • shouldRetain

      public boolean shouldRetain(JournalEntry entry, long currentTimeNanos)
      Description copied from interface: RetentionPolicy
      Check if an entry should be retained.
      Specified by:
      shouldRetain in interface RetentionPolicy
      Parameters:
      entry - The entry to check
      currentTimeNanos - Current time in nanoseconds
      Returns:
      true if the entry should be kept, false if it can be removed
    • 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. All components in this record class 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.
    • maxEntries

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