Record Class TtlDecayPolicy.LinearDecay

java.lang.Object
java.lang.Record
cloud.opencode.base.cache.ttl.TtlDecayPolicy.LinearDecay
Record Components:
initialTtl - the initial TTL | 初始过期时间
minimumTtl - the minimum TTL | 最小过期时间
decaySteps - the number of decay steps | 衰减步数
All Implemented Interfaces:
TtlDecayPolicy
Enclosing interface:
TtlDecayPolicy

public static record TtlDecayPolicy.LinearDecay(Duration initialTtl, Duration minimumTtl, int decaySteps) extends Record implements TtlDecayPolicy
Linear decay implementation 线性衰减实现
Since:
JDK 25, opencode-base-cache V2.0.5
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • LinearDecay

      public LinearDecay(Duration initialTtl, Duration minimumTtl, int decaySteps)
      public LinearDecay
  • Method Details

    • calculateDecayedTtl

      public Duration calculateDecayedTtl(long accessCount)
      Description copied from interface: TtlDecayPolicy
      Calculate decayed TTL based on access count 根据访问次数计算衰减后的 TTL
      Specified by:
      calculateDecayedTtl in interface TtlDecayPolicy
      Parameters:
      accessCount - number of times entry has been accessed | 条目被访问的次数
      Returns:
      decayed TTL | 衰减后的 TTL
    • 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.
    • initialTtl

      public Duration initialTtl()
      Returns the value of the initialTtl record component.
      Specified by:
      initialTtl in interface TtlDecayPolicy
      Returns:
      the value of the initialTtl record component
    • minimumTtl

      public Duration minimumTtl()
      Returns the value of the minimumTtl record component.
      Specified by:
      minimumTtl in interface TtlDecayPolicy
      Returns:
      the value of the minimumTtl record component
    • decaySteps

      public int decaySteps()
      Returns the value of the decaySteps record component.
      Returns:
      the value of the decaySteps record component