All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.soento.redis.support.GenericSerializationStrategy Maven / Gradle / Ivy

package com.soento.redis.support;

import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @author soento
 */
public class GenericSerializationStrategy extends BaseRedisSerializationStrategy {
    private static final StringRedisSerializer STRING_SERIALIZER = new StringRedisSerializer();
    private static final JdkSerializationRedisSerializer OBJECT_SERIALIZER = new JdkSerializationRedisSerializer();

    @Override
    protected  T deserializeInternal(byte[] bytes, Class clazz) {
        return (T) OBJECT_SERIALIZER.deserialize(bytes);
    }

    @Override
    protected String deserializeInternal(byte[] bytes) {
        return STRING_SERIALIZER.deserialize(bytes);
    }

    @Override
    protected byte[] serializeInternal(Object object) {
        return OBJECT_SERIALIZER.serialize(object);
    }

    @Override
    protected byte[] serializeInternal(String data) {
        return STRING_SERIALIZER.serialize(data);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy