package me.hao0.antares.store.serializer;
import com.alibaba.fastjson.JSON;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;
/**
* Author: haolin
* Email: haolin.h0@gmail.com
*/
public class FastJsonRedisSerializer implements RedisSerializer<Object> {
@Override
public byte[] serialize(Object o) throws SerializationException {
return JSON.toJSONBytes(o);
}
@Override
public Object deserialize(byte[] bytes) throws SerializationException {
if (bytes == null) return null;
return JSON.parse(bytes);
}
}