Package io.micronaut.cache.serialize
Class DefaultStringKeySerializer
java.lang.Object
io.micronaut.cache.serialize.DefaultStringKeySerializer
- All Implemented Interfaces:
io.micronaut.core.serialize.ObjectSerializer
public class DefaultStringKeySerializer
extends Object
implements io.micronaut.core.serialize.ObjectSerializer
The default key serializer used by caches that require serializing the keys as strings. Builds a key from the
configured cache name and String conversion of the object as dictated by ConversionService
.
Note this implementation does not support deserialization
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.core.serialize.ObjectSerializer
JDK
-
Constructor Summary
ConstructorDescriptionDefaultStringKeySerializer
(String cacheName, Charset charset, io.micronaut.core.convert.ConversionService conversionService) Construct a default serializer for given parameters. -
Method Summary
Modifier and TypeMethodDescription<T> Optional<T>
deserialize
(InputStream inputStream, Class<T> requiredType) Optional<byte[]>
void
serialize
(Object object, OutputStream outputStream) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.serialize.ObjectSerializer
deserialize, deserialize, deserialize, deserialize
-
Constructor Details
-
DefaultStringKeySerializer
public DefaultStringKeySerializer(String cacheName, Charset charset, io.micronaut.core.convert.ConversionService conversionService) Construct a default serializer for given parameters.- Parameters:
cacheName
- The cache key or namecharset
- The charset used for serialization and de-serializing instance from the to/from cacheconversionService
- To convert value/object from the cache to String
-
-
Method Details
-
serialize
public Optional<byte[]> serialize(Object object) throws io.micronaut.core.serialize.exceptions.SerializationException - Specified by:
serialize
in interfaceio.micronaut.core.serialize.ObjectSerializer
- Throws:
io.micronaut.core.serialize.exceptions.SerializationException
-
serialize
public void serialize(Object object, OutputStream outputStream) throws io.micronaut.core.serialize.exceptions.SerializationException - Specified by:
serialize
in interfaceio.micronaut.core.serialize.ObjectSerializer
- Throws:
io.micronaut.core.serialize.exceptions.SerializationException
-
deserialize
public <T> Optional<T> deserialize(InputStream inputStream, Class<T> requiredType) throws io.micronaut.core.serialize.exceptions.SerializationException - Specified by:
deserialize
in interfaceio.micronaut.core.serialize.ObjectSerializer
- Throws:
io.micronaut.core.serialize.exceptions.SerializationException
-