com.emily.infrastructure.redis.common.SerializationUtils Maven / Gradle / Ivy
The newest version!
package com.emily.infrastructure.redis.common;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.text.SimpleDateFormat;
/**
* Redis key value序列化方式工具
*
* @author : Emily
* @since : 2023/10/21 9:21 PM
*/
public class SerializationUtils {
/**
* 日期格式
*/
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* 初始化string序列化对象
*
* @return 字符串序列化对象
*/
public static StringRedisSerializer stringSerializer() {
return new StringRedisSerializer();
}
/**
* 初始化jackson序列化对象
*
* @return jackson序列化对象
*/
public static Jackson2JsonRedisSerializer