Record Class TtlDecayPolicy.ExponentialDecay

java.lang.Object
java.lang.Record
cloud.opencode.base.cache.ttl.TtlDecayPolicy.ExponentialDecay
Record Components:
initialTtl - the initial TTL | 初始过期时间
minimumTtl - the minimum TTL | 最小过期时间
decayFactor - the decay factor (0 to 1 exclusive) | 衰减因子(0到1之间)
All Implemented Interfaces:
TtlDecayPolicy
Enclosing interface:
TtlDecayPolicy

public static record TtlDecayPolicy.ExponentialDecay(Duration initialTtl, Duration minimumTtl, double decayFactor) extends Record implements TtlDecayPolicy
Exponential decay implementation 指数衰减实现
Since:
JDK 25, opencode-base-cache V2.0.5
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • ExponentialDecay

      public ExponentialDecay(Duration initialTtl, Duration minimumTtl, double decayFactor)
      public ExponentialDecay
  • 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
    • decayFactor

      public double decayFactor()
      Returns the value of the decayFactor record component.
      Returns:
      the value of the decayFactor record component