- Type Parameters:
K- Key type.V- Value type.
- All Known Implementing Classes:
ByteArrayCodec,StringCodec,Utf8StringCodec
public interface RedisCodec<K,V>
A
RedisCodec encodes keys and values sent to Redis, and decodes keys and values in the command output.
The methods are called by multiple threads and must be thread-safe.- Author:
- Will Glozer, Mark Paluch, Dimitris Mandalidis
-
Method Summary
Modifier and Type Method Description KdecodeKey(ByteBuffer bytes)Decode the key output by redis.VdecodeValue(ByteBuffer bytes)Decode the value output by redis.ByteBufferencodeKey(K key)Encode the key for output to redis.ByteBufferencodeValue(V value)Encode the value for output to redis.static <K, V> RedisCodec<K,V>of(RedisCodec<K,?> keyCodec, RedisCodec<?,V> valueCodec)
-
Method Details
-
of
- Type Parameters:
K- the type of the keyV- the type of the value- Parameters:
keyCodec- the codec to encode/decode the keys.valueCodec- the codec to encode/decode the values.- Returns:
- a composite
RedisCodec. - Since:
- 5.2
-
decodeKey
Decode the key output by redis.- Parameters:
bytes- Raw bytes of the key, must not benull.- Returns:
- The decoded key, may be
null.
-
decodeValue
Decode the value output by redis.- Parameters:
bytes- Raw bytes of the value, must not benull.- Returns:
- The decoded value, may be
null.
-
encodeKey
Encode the key for output to redis.- Parameters:
key- the key, may benull.- Returns:
- The encoded key, never
null.
-
encodeValue
Encode the value for output to redis.- Parameters:
value- the value, may benull.- Returns:
- The encoded value, never
null.
-