Class AbstractBinaryMemcacheEncoder<M extends BinaryMemcacheMessage>

All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler
Direct Known Subclasses:
BinaryMemcacheRequestEncoder, BinaryMemcacheResponseEncoder

@UnstableApi public abstract class AbstractBinaryMemcacheEncoder<M extends BinaryMemcacheMessage> extends AbstractMemcacheObjectEncoder<M>
A MessageToByteEncoder that encodes binary memcache messages into bytes.
  • Field Details

    • MINIMUM_HEADER_SIZE

      private static final int MINIMUM_HEADER_SIZE
      Every binary memcache message has at least a 24 bytes header.
      See Also:
  • Constructor Details

    • AbstractBinaryMemcacheEncoder

      public AbstractBinaryMemcacheEncoder()
  • Method Details

    • encodeMessage

      protected ByteBuf encodeMessage(ChannelHandlerContext ctx, M msg)
      Description copied from class: AbstractMemcacheObjectEncoder
      Take the given MemcacheMessage and encode it into a writable ByteBuf.
      Specified by:
      encodeMessage in class AbstractMemcacheObjectEncoder<M extends BinaryMemcacheMessage>
      Parameters:
      ctx - the channel handler context.
      msg - the message to encode.
      Returns:
      the ByteBuf representation of the message.
    • verifyLength

      private static int verifyLength(ByteBuf buf, int expectedLength, String name)
      The header is written from the lengths recorded in the message, so the readable bytes of the key and extras must still equal those recorded lengths. Otherwise the header would not describe the bytes that follow it.
    • encodeExtras

      private static void encodeExtras(ByteBuf buf, ByteBuf extras)
      Encode the extras.
      Parameters:
      buf - the ByteBuf to write into.
      extras - the extras to encode.
    • encodeKey

      private static void encodeKey(ByteBuf buf, ByteBuf key)
      Encode the key.
      Parameters:
      buf - the ByteBuf to write into.
      key - the key to encode.
    • encodeHeader

      protected abstract void encodeHeader(ByteBuf buf, M msg)
      Encode the header.

      This methods needs to be implemented by a sub class because the header is different for both requests and responses.

      Parameters:
      buf - the ByteBuf to write into.
      msg - the message to encode.