|
@@ -1,5 +1,7 @@
|
|
|
package com.gxzc.zen.common.config.cache.redis
|
|
|
|
|
|
+import com.fasterxml.jackson.databind.DeserializationFeature
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
|
|
import org.springframework.cache.CacheManager
|
|
|
import org.springframework.cache.annotation.EnableCaching
|
|
@@ -7,6 +9,7 @@ import org.springframework.context.annotation.Bean
|
|
|
import org.springframework.context.annotation.Configuration
|
|
|
import org.springframework.data.redis.cache.RedisCacheManager
|
|
|
import org.springframework.data.redis.core.RedisTemplate
|
|
|
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
|
|
|
import org.springframework.data.redis.serializer.StringRedisSerializer
|
|
|
|
|
|
/**
|
|
@@ -24,8 +27,10 @@ class RedisConfig {
|
|
|
@Bean
|
|
|
fun cacheManager(redisTemplate: RedisTemplate<Any, Any>): CacheManager {
|
|
|
return RedisCacheManager(redisTemplate.apply {
|
|
|
- keySerializer = StringRedisSerializer()
|
|
|
- hashKeySerializer = StringRedisSerializer()
|
|
|
+ val stringRedisSerializer = StringRedisSerializer()
|
|
|
+ keySerializer = stringRedisSerializer
|
|
|
+ hashKeySerializer = stringRedisSerializer
|
|
|
+ valueSerializer = GenericJackson2JsonRedisSerializer()
|
|
|
})
|
|
|
}
|
|
|
}
|