public interface KeyCodec<K> extends Codec<K>
A KeyCodec is a String
Codec
that is tasked
with the optimal performance of encoding and decoding String keys
for use by connector implementations that support such extended
mechanisms.
This interface is projected to be implemented by a key caching mechanism suitable for employment in usage scenarios where a finite set of keys is repeatedly employed to accomplish domain specific tasks.
For example, a common Redis pattern is the use of atomic counters to increment IDs. Whenever this pattern is used, the key for the ID(s) will be repeatedly encoded and decoded by a non-optimized client which can not make indiscriminate decisions regarding such optimizations.
A key cache, implementing KeyCodec
, for example, can be used to indicate to
the client that for keys, the default codec (which is basically delegating to
String
's String.getBytes()
and String.String(byte[], int, int)
)
should not be used and that the client should use the object implementing this
to accomplish the same task.
This is just a marker interface beyond that.
Copyright © 2009–2019. All rights reserved.