Class StringRedisSerializer
java.lang.Object
org.springframework.data.redis.serializer.StringRedisSerializer
- All Implemented Interfaces:
RedisSerializer<String>
Simple
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.
- Author:
- Costin Leau, Christoph Strobl, Mark Paluch
-
Field Summary
Modifier and TypeFieldDescriptionstatic final StringRedisSerializer
StringRedisSerializer
to use ISO Latin Alphabet No. 1, a.k.a.static final StringRedisSerializer
StringRedisSerializer
to use 7 bit ASCII, a.k.a.static final StringRedisSerializer
StringRedisSerializer
to use 8 bit UCS Transformation Format. -
Constructor Summary
ConstructorDescriptionCreates a newStringRedisSerializer
usingUTF-8
.StringRedisSerializer
(Charset charset) Creates a newStringRedisSerializer
using the givenCharset
to encode and decode strings. -
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(byte[] bytes) Deserialize an object from the given binary data.Class<?>
Return the serializer target type.byte[]
Serialize the given object to binary data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.redis.serializer.RedisSerializer
canSerialize
-
Field Details
-
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.- Since:
- 2.1
- See Also:
-
ISO_8859_1
StringRedisSerializer
to use ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.- Since:
- 2.1
- See Also:
-
UTF_8
StringRedisSerializer
to use 8 bit UCS Transformation Format.- Since:
- 2.1
- See Also:
-
-
Constructor Details
-
StringRedisSerializer
public StringRedisSerializer()Creates a newStringRedisSerializer
usingUTF-8
. -
StringRedisSerializer
Creates a newStringRedisSerializer
using the givenCharset
to encode and decode strings.- Parameters:
charset
- must not be null.
-
-
Method Details
-
serialize
Description copied from interface:RedisSerializer
Serialize the given object to binary data.- Specified by:
serialize
in interfaceRedisSerializer<String>
- Parameters:
value
- object to serialize. Can be null.- Returns:
- the equivalent binary data. Can be null.
-
deserialize
Description copied from interface:RedisSerializer
Deserialize an object from the given binary data.- Specified by:
deserialize
in interfaceRedisSerializer<String>
- Parameters:
bytes
- object binary representation. Can be null.- Returns:
- the equivalent object instance. Can be null.
-
getTargetType
Description copied from interface:RedisSerializer
Return the serializer target type.- Specified by:
getTargetType
in interfaceRedisSerializer<String>
- Returns:
- the serializer target type.
-