|  |  |  | 
|---|
|  |  |  | package com.genersoft.iot.vmp.conf.redis; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.genersoft.iot.vmp.utils.redis.FastJsonRedisSerializer; | 
|---|
|  |  |  | import com.alibaba.fastjson2.support.spring.data.redis.GenericFastJsonRedisSerializer; | 
|---|
|  |  |  | import org.springframework.context.annotation.Bean; | 
|---|
|  |  |  | import org.springframework.context.annotation.Configuration; | 
|---|
|  |  |  | import org.springframework.data.redis.connection.RedisConnectionFactory; | 
|---|
|  |  |  | 
|---|
|  |  |  | public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { | 
|---|
|  |  |  | RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>(); | 
|---|
|  |  |  | // 使用fastJson序列化 | 
|---|
|  |  |  | FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class); | 
|---|
|  |  |  | GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer(); | 
|---|
|  |  |  | // value值的序列化采用fastJsonRedisSerializer | 
|---|
|  |  |  | redisTemplate.setValueSerializer(fastJsonRedisSerializer); | 
|---|
|  |  |  | redisTemplate.setHashValueSerializer(fastJsonRedisSerializer); | 
|---|