Record Class EvictionPolicy.LFU<T>

java.lang.Object
java.lang.Record
cloud.opencode.base.pool.policy.EvictionPolicy.LFU<T>
Type Parameters:
T - the pooled object type - 池化对象类型
Record Components:
minBorrowCount - the minimum borrow count - 最小借用次数
All Implemented Interfaces:
EvictionPolicy<T>
Enclosing interface:
EvictionPolicy<T>

public static record EvictionPolicy.LFU<T>(long minBorrowCount) extends Record implements EvictionPolicy<T>
Least Frequently Used eviction policy. 最不经常使用驱逐策略。

Evicts objects that have been borrowed fewer than minBorrowCount times.

驱逐借用次数少于minBorrowCount的对象。

Since:
JDK 25, opencode-base-pool V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • LFU

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

    • evict

      public boolean evict(PooledObject<T> obj, EvictionContext context)
      Description copied from interface: EvictionPolicy
      Determines if the object should be evicted. 确定对象是否应被驱逐。
      Specified by:
      evict in interface EvictionPolicy<T>
      Parameters:
      obj - the pooled object - 池化对象
      context - the eviction context - 驱逐上下文
      Returns:
      true if should evict - 如果应驱逐返回true
    • 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.
    • minBorrowCount

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