Package io.lettuce.core.protocol
Class DecodeBufferPolicies
- java.lang.Object
-
- io.lettuce.core.protocol.DecodeBufferPolicies
-
public abstract class DecodeBufferPolicies extends Object
Utility class to construct commonly usedDecodeBufferPolicy
objects.- Since:
- 6.0
- Author:
- Mark Paluch
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DecodeBufferPolicy
always()
DecodeBufferPolicy
thatdiscards read bytes
after each decoding phase.static DecodeBufferPolicy
alwaysSome()
DecodeBufferPolicy
thatdiscards some read bytes
after each decoding phase.static DecodeBufferPolicy
ratio(float bufferUsageRatio)
Ratio-based discard policy that considers the capacity vs.
-
-
-
Method Detail
-
ratio
public static DecodeBufferPolicy ratio(float bufferUsageRatio)
Ratio-based discard policy that considers the capacity vs. usage of the aggregation buffer. This strategy optimizes for CPU usage vs. memory usage by considering the usage ratio. Higher values lead to more memory usage.The ratio is calculated with
bufferUsageRatio/(1+bufferUsageRatio)
which gives 50% for a value of1
, 66% for2
and so on.- Parameters:
bufferUsageRatio
- the buffer usage ratio. Must be between0
and2^31-1
, typically a value between 1 and 10 representing 50% to 90%.- Returns:
- the new strategy object.
-
always
public static DecodeBufferPolicy always()
DecodeBufferPolicy
thatdiscards read bytes
after each decoding phase. This strategy hast the most memory efficiency but also leads to more CPU pressure.- Returns:
- the strategy object.
-
alwaysSome
public static DecodeBufferPolicy alwaysSome()
DecodeBufferPolicy
thatdiscards some read bytes
after each decoding phase. This strategy might discard some, all, or none of read bytes depending on its internal implementation to reduce overall memory bandwidth consumption at the cost of potentially additional memory consumption.- Returns:
- the strategy object.
-
-