Class JdkSerializationRedisSerializer
java.lang.Object
org.springframework.data.redis.serializer.JdkSerializationRedisSerializer
- All Implemented Interfaces:
RedisSerializer<Object>
Java Serialization
RedisSerializer.
Delegates to the default (Java-based) serializer
and deserializer.
This serializer can be constructed with either a custom ClassLoader
or custom converters.
- Author:
- Mark Pollack, Costin Leau, Mark Paluch, Christoph Strobl, John Blum
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newJdkSerializationRedisSerializerusing the defaultClassLoader.JdkSerializationRedisSerializer(ClassLoader classLoader) Creates a newJdkSerializationRedisSerializerwith the givenClassLoaderused to resolvetypesduring deserialization.JdkSerializationRedisSerializer(Converter<Object, byte[]> serializer, Converter<byte[], Object> deserializer) Creates a newJdkSerializationRedisSerializerusingconvertersto serialize and deserializeobjects. -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(byte[] bytes) Deserialize an object from the given binary data.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, getTargetType
-
Constructor Details
-
JdkSerializationRedisSerializer
public JdkSerializationRedisSerializer()Creates a newJdkSerializationRedisSerializerusing the defaultClassLoader. -
JdkSerializationRedisSerializer
Creates a newJdkSerializationRedisSerializerwith the givenClassLoaderused to resolvetypesduring deserialization.- Parameters:
classLoader-ClassLoaderused to resolvetypesfor deserialization; can be null.- Since:
- 1.7
-
JdkSerializationRedisSerializer
public JdkSerializationRedisSerializer(Converter<Object, byte[]> serializer, Converter<byte[], Object> deserializer) Creates a newJdkSerializationRedisSerializerusingconvertersto serialize and deserializeobjects.- Parameters:
serializer-Converterused to serialize anObjectto a byte array; must not be null.deserializer-Converterused to deserialize and convert a byte arra into anObject; must not be null- Throws:
IllegalArgumentException- if either the givenserializerordeserializerare null.- Since:
- 1.7
-
-
Method Details
-
serialize
Description copied from interface:RedisSerializerSerialize the given object to binary data.- Specified by:
serializein interfaceRedisSerializer<Object>- 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<Object>- Parameters:
bytes- object binary representation. Can be null.- Returns:
- the equivalent object instance. Can be null.
-