public class StringCodec extends Object implements RedisCodec<String,String>, ToByteBufEncoder<String,String>
RedisCodec encodes and decodes String keys and values using a specified
Charset. It accepts provided buffers so it does not need to allocate buffers during encoding.| Modifier and Type | Field and Description |
|---|---|
static StringCodec |
ASCII |
static StringCodec |
UTF8 |
| Constructor and Description |
|---|
StringCodec()
Creates a new
StringCodec with the default charset. |
StringCodec(Charset charset)
Creates a new
StringCodec for the given Charset that encodes and decodes keys and values. |
| Modifier and Type | Method and Description |
|---|---|
String |
decodeKey(ByteBuffer bytes)
Decode the key output by redis.
|
String |
decodeValue(ByteBuffer bytes)
Decode the value output by redis.
|
void |
encode(String str,
ByteBuf target) |
ByteBuffer |
encodeKey(String key)
Encode the key for output to redis.
|
void |
encodeKey(String key,
ByteBuf target)
Encode the key for output to redis.
|
ByteBuffer |
encodeValue(String value)
Encode the value for output to redis.
|
void |
encodeValue(String value,
ByteBuf target)
Encode the value for output to redis.
|
int |
estimateSize(Object keyOrValue)
Estimates the size of the resulting byte stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitofpublic static final StringCodec UTF8
public static final StringCodec ASCII
public StringCodec()
StringCodec with the default charset. The default is determined
from the file.encoding system property.public StringCodec(Charset charset)
StringCodec for the given Charset that encodes and decodes keys and values.charset - must not be null.public void encodeKey(String key, ByteBuf target)
ToByteBufEncoderencodeKey in interface ToByteBufEncoder<String,String>key - the key, may be null.target - the target buffer, must not be null.public int estimateSize(Object keyOrValue)
ToByteBufEncoderestimateSize in interface ToByteBufEncoder<String,String>keyOrValue - the key or value, may be null.public void encodeValue(String value, ByteBuf target)
ToByteBufEncoderencodeValue in interface ToByteBufEncoder<String,String>value - the value, may be null.target - the target buffer, must not be null.public String decodeKey(ByteBuffer bytes)
RedisCodecdecodeKey in interface RedisCodec<String,String>bytes - Raw bytes of the key, must not be null.public String decodeValue(ByteBuffer bytes)
RedisCodecdecodeValue in interface RedisCodec<String,String>bytes - Raw bytes of the value, must not be null.public ByteBuffer encodeKey(String key)
RedisCodecencodeKey in interface RedisCodec<String,String>key - the key, may be null.public ByteBuffer encodeValue(String value)
RedisCodecencodeValue in interface RedisCodec<String,String>value - the value, may be null.Copyright © 2019 lettuce.io. All rights reserved.