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
FieldsModifier and TypeFieldDescriptionstatic final StringRedisSerializerStringRedisSerializerto use ISO Latin Alphabet No. 1, a.k.a.static final StringRedisSerializerStringRedisSerializerto use 7 bit ASCII, a.k.a.static final StringRedisSerializerStringRedisSerializerto use 8 bit UCS Transformation Format. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newStringRedisSerializerusingUTF-8.StringRedisSerializer(Charset charset) Creates a newStringRedisSerializerusing the givenCharsetto 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, waitMethods inherited from interface org.springframework.data.redis.serializer.RedisSerializer
canSerialize
-
Field Details
-
US_ASCII
StringRedisSerializerto 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
StringRedisSerializerto use ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.- Since:
- 2.1
- See Also:
-
UTF_8
StringRedisSerializerto use 8 bit UCS Transformation Format.- Since:
- 2.1
- See Also:
-
-
Constructor Details
-
StringRedisSerializer
public StringRedisSerializer()Creates a newStringRedisSerializerusingUTF-8. -
StringRedisSerializer
Creates a newStringRedisSerializerusing the givenCharsetto encode and decode strings.- Parameters:
charset- must not be null.
-
-
Method Details
-
serialize
Description copied from interface:RedisSerializerSerialize the given object to binary data.- Specified by:
serializein interfaceRedisSerializer<String>- Parameters:
value- object to serialize. Can be null.- Returns:
- the equivalent binary data. Can be null.
-
deserialize
Description copied from interface:RedisSerializerDeserialize an object from the given binary data.- Specified by:
deserializein interfaceRedisSerializer<String>- Parameters:
bytes- object binary representation. Can be null.- Returns:
- the equivalent object instance. Can be null.
-
getTargetType
Description copied from interface:RedisSerializerReturn the serializer target type.- Specified by:
getTargetTypein interfaceRedisSerializer<String>- Returns:
- the serializer target type.
-