Skip to content

Instantly share code, notes, and snippets.

@mp911de
Created May 12, 2017 06:58
Show Gist options
  • Select an option

  • Save mp911de/a94866d95de613b73c76100e1be86852 to your computer and use it in GitHub Desktop.

Select an option

Save mp911de/a94866d95de613b73c76100e1be86852 to your computer and use it in GitHub Desktop.
import java.nio.ByteBuffer;
import com.lambdaworks.redis.codec.ByteArrayCodec;
import com.lambdaworks.redis.codec.RedisCodec;
import com.lambdaworks.redis.codec.StringCodec;
/**
* @author Mark Paluch
*/
class StringByteRedisCodec implements RedisCodec<String, byte[]> {
public String decodeKey(ByteBuffer byteBuffer) {
return StringCodec.UTF8.decodeKey(byteBuffer);
}
public byte[] decodeValue(ByteBuffer byteBuffer) {
return ByteArrayCodec.INSTANCE.decodeValue(byteBuffer);
}
public ByteBuffer encodeKey(String s) {
return StringCodec.UTF8.encodeKey(s);
}
public ByteBuffer encodeValue(byte[] bytes) {
return ByteArrayCodec.INSTANCE.encodeValue(bytes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment