Spring Data RedisTemplate: Serializing the Value and HashValue

懵懂的女人 提交于 2019-12-01 06:02:37

Redis stores keys and values as string. It's up to your persistence layer to handle the parsing. In the example, User is a POJO and not a String. I suggest that you use JacksonJsonRedisSerializer instead of StringRedisSerializer. This way you're storing json as your value.

<bean id="userJsonRedisSerializer" 
    class="org.springframework.data.redis.serializer.JacksonJsonRedisSerializer">
    <constructor-arg type="java.lang.Class" value="com.mycompany.redis.domain.User"/>
</bean>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!