java.lang.Object
io.lettuce.core.protocol.DecodeBufferPolicies
public abstract class DecodeBufferPolicies extends Object
Utility class to construct commonly used
DecodeBufferPolicy objects.- Since:
- 6.0
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description static DecodeBufferPolicyalways()DecodeBufferPolicythatdiscards read bytesafter each decoding phase.static DecodeBufferPolicyalwaysSome()DecodeBufferPolicythatdiscards some read bytesafter each decoding phase.static DecodeBufferPolicyratio(float bufferUsageRatio)Ratio-based discard policy that considers the capacity vs.
-
Method Details
-
ratio
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% for2and so on.- Parameters:
bufferUsageRatio- the buffer usage ratio. Must be between0and2^31-1, typically a value between 1 and 10 representing 50% to 90%.- Returns:
- the new strategy object.
-
always
DecodeBufferPolicythatdiscards read bytesafter each decoding phase. This strategy hast the most memory efficiency but also leads to more CPU pressure.- Returns:
- the strategy object.
-
alwaysSome
DecodeBufferPolicythatdiscards some read bytesafter 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.
-