Module lettuce.core

Class DecodeBufferPolicies

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 Details

    • 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 of 1, 66% for 2 and so on.

      Parameters:
      bufferUsageRatio - the buffer usage ratio. Must be between 0 and 2^31-1, typically a value between 1 and 10 representing 50% to 90%.
      Returns:
      the new strategy object.
    • always

      public static DecodeBufferPolicy always()
      DecodeBufferPolicy that discards 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 that discards 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.