- All Known Implementing Classes:
ByteArrayCodec,StringCodec,Utf8StringCodec
public interface ToByteBufEncoder<K,V>
Optimized encoder that encodes keys and values directly on a
ByteBuf. This encoder does not allocate buffers, it just
encodes data to existing buffers.
Classes implementing ToByteBufEncoder are required to implement RedisCodec as well. You should implement also
the RedisCodec.encodeKey(Object) and RedisCodec.encodeValue(Object) methods to ensure compatibility for users
that access the RedisCodec API only.
- Since:
- 4.3
- Author:
- Mark Paluch
-
Method Summary
Modifier and Type Method Description voidencodeKey(K key, ByteBuf target)Encode the key for output to redis.voidencodeValue(V value, ByteBuf target)Encode the value for output to redis.intestimateSize(Object keyOrValue)Estimates the size of the resulting byte stream.
-
Method Details
-
encodeKey
Encode the key for output to redis.- Parameters:
key- the key, may benull.target- the target buffer, must not benull.
-
encodeValue
Encode the value for output to redis.- Parameters:
value- the value, may benull.target- the target buffer, must not benull.
-
estimateSize
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.- Parameters:
keyOrValue- the key or value, may benull.- Returns:
- the estimated number of bytes in the encoded representation.
-