Record Class EvictionPolicy.MaxAge<T>
java.lang.Object
java.lang.Record
cloud.opencode.base.pool.policy.EvictionPolicy.MaxAge<T>
- Type Parameters:
T- the pooled object type - 池化对象类型- Record Components:
maxLifetime- the maximum object lifetime - 最大对象生命周期
- All Implemented Interfaces:
EvictionPolicy<T>
- Enclosing interface:
EvictionPolicy<T>
public static record EvictionPolicy.MaxAge<T>(Duration maxLifetime)
extends Record
implements EvictionPolicy<T>
Maximum age eviction policy.
最大生命周期驱逐策略。
Evicts objects that have exceeded a maximum lifetime based on creation time. Essential for database connections that must be recycled periodically.
驱逐超过最大生命周期的对象(基于创建时间,而非空闲时间)。 对于必须定期回收的数据库连接至关重要。
- Since:
- JDK 25, opencode-base-pool V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface EvictionPolicy
EvictionPolicy.Composite<T>, EvictionPolicy.IdleTime<T>, EvictionPolicy.LFU<T>, EvictionPolicy.LRU<T>, EvictionPolicy.MaxAge<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.booleanevict(PooledObject<T> obj, EvictionContext context) Determines if the object should be evicted.final inthashCode()Returns a hash code value for this object.Returns the value of themaxLifetimerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
MaxAge
Creates an instance of aMaxAgerecord class.- Parameters:
maxLifetime- the value for themaxLifetimerecord component
-
-
Method Details
-
evict
Description copied from interface:EvictionPolicyDetermines if the object should be evicted. 确定对象是否应被驱逐。- Specified by:
evictin interfaceEvictionPolicy<T>- Parameters:
obj- the pooled object - 池化对象context- the eviction context - 驱逐上下文- Returns:
- true if should evict - 如果应驱逐返回true
-
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 withObjects::equals(Object,Object). -
maxLifetime
Returns the value of themaxLifetimerecord component.- Returns:
- the value of the
maxLifetimerecord component
-