Module lettuce.core

Class ByteArrayCodec

java.lang.Object
io.lettuce.core.codec.ByteArrayCodec
All Implemented Interfaces:
RedisCodec<byte[],​byte[]>, ToByteBufEncoder<byte[],​byte[]>

public class ByteArrayCodec
extends Object
implements RedisCodec<byte[],​byte[]>, ToByteBufEncoder<byte[],​byte[]>
A RedisCodec that uses plain byte arrays without further transformations.
Since:
3.3
Author:
Mark Paluch
  • Field Details

  • Constructor Details

    • ByteArrayCodec

      public ByteArrayCodec()
  • Method Details

    • encodeKey

      public void encodeKey​(byte[] key, ByteBuf target)
      Description copied from interface: ToByteBufEncoder
      Encode the key for output to redis.
      Specified by:
      encodeKey in interface ToByteBufEncoder<byte[],​byte[]>
      Parameters:
      key - the key, may be null.
      target - the target buffer, must not be null.
    • encodeValue

      public void encodeValue​(byte[] value, ByteBuf target)
      Description copied from interface: ToByteBufEncoder
      Encode the value for output to redis.
      Specified by:
      encodeValue in interface ToByteBufEncoder<byte[],​byte[]>
      Parameters:
      value - the value, may be null.
      target - the target buffer, must not be null.
    • estimateSize

      public int estimateSize​(Object keyOrValue)
      Description copied from interface: ToByteBufEncoder
      Estimates the size of the resulting byte stream. This method is called for keys and values to estimate the size for the temporary buffer to allocate.
      Specified by:
      estimateSize in interface ToByteBufEncoder<byte[],​byte[]>
      Parameters:
      keyOrValue - the key or value, may be null.
      Returns:
      the estimated number of bytes in the encoded representation.
    • decodeKey

      public byte[] decodeKey​(ByteBuffer bytes)
      Description copied from interface: RedisCodec
      Decode the key output by redis.
      Specified by:
      decodeKey in interface RedisCodec<byte[],​byte[]>
      Parameters:
      bytes - Raw bytes of the key, must not be null.
      Returns:
      The decoded key, may be null.
    • decodeValue

      public byte[] decodeValue​(ByteBuffer bytes)
      Description copied from interface: RedisCodec
      Decode the value output by redis.
      Specified by:
      decodeValue in interface RedisCodec<byte[],​byte[]>
      Parameters:
      bytes - Raw bytes of the value, must not be null.
      Returns:
      The decoded value, may be null.
    • encodeKey

      public ByteBuffer encodeKey​(byte[] key)
      Description copied from interface: RedisCodec
      Encode the key for output to redis.
      Specified by:
      encodeKey in interface RedisCodec<byte[],​byte[]>
      Parameters:
      key - the key, may be null.
      Returns:
      The encoded key, never null.
    • encodeValue

      public ByteBuffer encodeValue​(byte[] value)
      Description copied from interface: RedisCodec
      Encode the value for output to redis.
      Specified by:
      encodeValue in interface RedisCodec<byte[],​byte[]>
      Parameters:
      value - the value, may be null.
      Returns:
      The encoded value, never null.