Class AbstractBinaryMemcacheEncoder<M extends BinaryMemcacheMessage>

    • Field Detail

      • MINIMUM_HEADER_SIZE

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

      • AbstractBinaryMemcacheEncoder

        public AbstractBinaryMemcacheEncoder()
    • Method Detail

      • verifyLength

        private static int verifyLength​(ByteBuf buf,
                                        int expectedLength,
                                        java.lang.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.