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
-
Nested Class Summary
Nested classes/interfaces inherited from interface RetentionPolicy
RetentionPolicy.Composite, RetentionPolicy.SizeBased, RetentionPolicy.TimeBased -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longReturns the value of themaxEntriesrecord component.booleanshouldRetain(JournalEntry entry, long currentTimeNanos) Check if an entry should be retained.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SizeBased
public SizeBased(long maxEntries) Creates an instance of aSizeBasedrecord class.- Parameters:
maxEntries- the value for themaxEntriesrecord component
-
-
Method Details
-
shouldRetain
Description copied from interface:RetentionPolicyCheck if an entry should be retained.- Specified by:
shouldRetainin interfaceRetentionPolicy- Parameters:
entry- The entry to checkcurrentTimeNanos- Current time in nanoseconds- Returns:
- true if the entry should be kept, false if it can be removed
-
toString
-
hashCode
-
equals
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 thecomparemethod from their corresponding wrapper classes. -
maxEntries
public long maxEntries()Returns the value of themaxEntriesrecord component.- Returns:
- the value of the
maxEntriesrecord component
-