public class StringRedisSerializer extends Object implements RedisSerializer<String>
String to byte[] (and back) serializer. Converts Strings
into bytes and vice-versa using the specified charset (by default UTF-8).
Useful when the interaction with the Redis happens mainly through Strings.
Does not perform any null conversion since empty strings are valid keys/values.
| Modifier and Type | Field and Description |
|---|---|
static StringRedisSerializer |
ISO_8859_1
StringRedisSerializer to use ISO Latin Alphabet No. 1, a.k.a. |
static StringRedisSerializer |
US_ASCII
StringRedisSerializer to use 7 bit ASCII, a.k.a. |
static StringRedisSerializer |
UTF_8
StringRedisSerializer to use 8 bit UCS Transformation Format. |
| Constructor and Description |
|---|
StringRedisSerializer()
Creates a new
StringRedisSerializer using UTF-8. |
StringRedisSerializer(Charset charset)
Creates a new
StringRedisSerializer using the given Charset to encode and decode strings. |
| Modifier and Type | Method and Description |
|---|---|
String |
deserialize(byte[] bytes)
Deserialize an object from the given binary data.
|
byte[] |
serialize(String string)
Serialize the given object to binary data.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitjava, java, json, stringpublic static final StringRedisSerializer US_ASCII
StringRedisSerializer to use 7 bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode
character set.StandardCharsets.US_ASCIIpublic static final StringRedisSerializer ISO_8859_1
StringRedisSerializer to use ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.StandardCharsets.ISO_8859_1public static final StringRedisSerializer UTF_8
StringRedisSerializer to use 8 bit UCS Transformation Format.StandardCharsets.UTF_8public StringRedisSerializer()
StringRedisSerializer using UTF-8.public StringRedisSerializer(Charset charset)
StringRedisSerializer using the given Charset to encode and decode strings.charset - must not be null.public String deserialize(@Nullable byte[] bytes)
RedisSerializerdeserialize in interface RedisSerializer<String>bytes - object binary representation. Can be null.public byte[] serialize(@Nullable String string)
RedisSerializerserialize in interface RedisSerializer<String>string - object to serialize. Can be null.Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.