K - Key type.V - Value type.public interface RedisCodec<K,V>
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.
K represents a Redis key (or a hash field of such a key) routed through encodeKey(Object) /
decodeKey(ByteBuffer).
V represents a value that is stored under a Redis key (or under a hash field of such a key) and that the server
returns as opaque bytes; values round-trip through encodeValue(Object) / decodeValue(ByteBuffer). Protocol
literals (command keywords, DSL expressions, index/dictionary/synonym names, module/expander identifiers, and other metadata
interpreted by the server) are not values in this sense and should not be routed through V.
| Modifier and Type | Method and 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)
|
static <K,V> RedisCodec<K,V> of(RedisCodec<K,?> keyCodec, RedisCodec<?,V> valueCodec)
K - the type of the keyV - the type of the valuekeyCodec - the codec to encode/decode the keys.valueCodec - the codec to encode/decode the values.RedisCodec.K decodeKey(ByteBuffer bytes)
bytes - Raw bytes of the key, must not be null.null.V decodeValue(ByteBuffer bytes)
bytes - Raw bytes of the value, must not be null.null.ByteBuffer encodeKey(K key)
key - the key, may be null.null.ByteBuffer encodeValue(V value)
value - the value, may be null.null.Copyright © 2026 lettuce.io. All rights reserved.