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
ConstructorDescriptionCreates a newJdkSerializationRedisSerializer
using the defaultClassLoader
.JdkSerializationRedisSerializer
(ClassLoader classLoader) Creates a newJdkSerializationRedisSerializer
with the givenClassLoader
used to resolvetypes
during deserialization.JdkSerializationRedisSerializer
(Converter<Object, byte[]> serializer, Converter<byte[], Object> deserializer) Creates a newJdkSerializationRedisSerializer
usingconverters
to 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, wait
Methods inherited from interface org.springframework.data.redis.serializer.RedisSerializer
canSerialize, getTargetType
-
Constructor Details
-
JdkSerializationRedisSerializer
public JdkSerializationRedisSerializer()Creates a newJdkSerializationRedisSerializer
using the defaultClassLoader
. -
JdkSerializationRedisSerializer
Creates a newJdkSerializationRedisSerializer
with the givenClassLoader
used to resolvetypes
during deserialization.- Parameters:
classLoader
-ClassLoader
used to resolvetypes
for deserialization; can be null.- Since:
- 1.7
-
JdkSerializationRedisSerializer
public JdkSerializationRedisSerializer(Converter<Object, byte[]> serializer, Converter<byte[], Object> deserializer) Creates a newJdkSerializationRedisSerializer
usingconverters
to serialize and deserializeobjects
.- Parameters:
serializer
-Converter
used to serialize anObject
to a byte array; must not be null.deserializer
-Converter
used to deserialize and convert a byte arra into anObject
; must not be null- Throws:
IllegalArgumentException
- if either the givenserializer
ordeserializer
are null.- Since:
- 1.7
-
-
Method Details
-
serialize
Description copied from interface:RedisSerializer
Serialize the given object to binary data.- Specified by:
serialize
in interfaceRedisSerializer<Object>
- 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<Object>
- Parameters:
bytes
- object binary representation. Can be null.- Returns:
- the equivalent object instance. Can be null.
-