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
-
Nested Class Summary
Nested classes/interfaces inherited from interface TtlDecayPolicy
TtlDecayPolicy.ExponentialDecay, TtlDecayPolicy.LinearDecay, TtlDecayPolicy.NoDecay, TtlDecayPolicy.Step, TtlDecayPolicy.StepDecay -
Constructor Summary
ConstructorsConstructorDescriptionExponentialDecay(Duration initialTtl, Duration minimumTtl, double decayFactor) public ExponentialDecay -
Method Summary
Modifier and TypeMethodDescriptioncalculateDecayedTtl(long accessCount) Calculate decayed TTL based on access count 根据访问次数计算衰减后的 TTLdoubleReturns the value of thedecayFactorrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theinitialTtlrecord component.Returns the value of theminimumTtlrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ExponentialDecay
-
-
Method Details
-
calculateDecayedTtl
Description copied from interface:TtlDecayPolicyCalculate decayed TTL based on access count 根据访问次数计算衰减后的 TTL- Specified by:
calculateDecayedTtlin interfaceTtlDecayPolicy- Parameters:
accessCount- number of times entry has been accessed | 条目被访问的次数- Returns:
- decayed TTL | 衰减后的 TTL
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
initialTtl
Returns the value of theinitialTtlrecord component.- Specified by:
initialTtlin interfaceTtlDecayPolicy- Returns:
- the value of the
initialTtlrecord component
-
minimumTtl
Returns the value of theminimumTtlrecord component.- Specified by:
minimumTtlin interfaceTtlDecayPolicy- Returns:
- the value of the
minimumTtlrecord component
-
decayFactor
public double decayFactor()Returns the value of thedecayFactorrecord component.- Returns:
- the value of the
decayFactorrecord component
-