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
-
Nested Class Summary
Nested classes/interfaces inherited from interface TtlDecayPolicy
TtlDecayPolicy.ExponentialDecay, TtlDecayPolicy.LinearDecay, TtlDecayPolicy.NoDecay, TtlDecayPolicy.Step, TtlDecayPolicy.StepDecay -
Constructor Summary
ConstructorsConstructorDescriptionLinearDecay(Duration initialTtl, Duration minimumTtl, int decaySteps) public LinearDecay -
Method Summary
Modifier and TypeMethodDescriptioncalculateDecayedTtl(long accessCount) Calculate decayed TTL based on access count 根据访问次数计算衰减后的 TTLintReturns the value of thedecayStepsrecord 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
-
LinearDecay
-
-
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
-
decaySteps
public int decaySteps()Returns the value of thedecayStepsrecord component.- Returns:
- the value of the
decayStepsrecord component
-