Package io.lettuce.core.codec
Interface RedisCodec<K,V>
-
- Type Parameters:
K
- Key type.V
- Value type.
- All Known Implementing Classes:
ByteArrayCodec
,StringCodec
,Utf8StringCodec
public interface RedisCodec<K,V>
ARedisCodec
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
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description K
decodeKey(ByteBuffer bytes)
Decode the key output by redis.V
decodeValue(ByteBuffer bytes)
Decode the value output by redis.ByteBuffer
encodeKey(K key)
Encode the key for output to redis.ByteBuffer
encodeValue(V value)
Encode the value for output to redis.static <K,V>
RedisCodec<K,V>of(RedisCodec<K,?> keyCodec, RedisCodec<?,V> valueCodec)
-
-
-
Method Detail
-
of
static <K,V> RedisCodec<K,V> of(RedisCodec<K,?> keyCodec, RedisCodec<?,V> valueCodec)
- 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
K decodeKey(ByteBuffer bytes)
Decode the key output by redis.- Parameters:
bytes
- Raw bytes of the key, must not benull
.- Returns:
- The decoded key, may be
null
.
-
decodeValue
V decodeValue(ByteBuffer bytes)
Decode the value output by redis.- Parameters:
bytes
- Raw bytes of the value, must not benull
.- Returns:
- The decoded value, may be
null
.
-
encodeKey
ByteBuffer encodeKey(K key)
Encode the key for output to redis.- Parameters:
key
- the key, may benull
.- Returns:
- The encoded key, never
null
.
-
encodeValue
ByteBuffer encodeValue(V value)
Encode the value for output to redis.- Parameters:
value
- the value, may benull
.- Returns:
- The encoded value, never
null
.
-
-