|
@@ -7,39 +7,89 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
|
|
+import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
|
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
|
|
-import org.springframework.data.redis.serializer.RedisSerializer;
|
|
|
-import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|
|
+import org.springframework.data.redis.core.script.DefaultRedisScript;
|
|
|
+import org.springframework.data.redis.core.script.RedisScript;
|
|
|
+import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
|
|
+import org.springframework.data.redis.serializer.*;
|
|
|
+import org.springframework.scripting.support.ResourceScriptSource;
|
|
|
|
|
|
@Configuration
|
|
|
public class EduTravelCacheConfig {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public RedisCacheConfiguration redisCacheConfiguration(){
|
|
|
+ RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
|
|
|
+
|
|
|
+ redisCacheConfiguration = redisCacheConfiguration.
|
|
|
+ serializeValuesWith(RedisSerializationContext.SerializationPair.
|
|
|
+ fromSerializer(new GenericJackson2JsonRedisSerializer()));
|
|
|
+ return redisCacheConfiguration;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- @Bean(name = "redisTemplate")
|
|
|
- public RedisTemplate<String, Object> getRedisTemplate(RedisConnectionFactory factory) {
|
|
|
- RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
|
|
|
- redisTemplate.setConnectionFactory(factory);
|
|
|
- RedisSerializer stringSerializer = new StringRedisSerializer();
|
|
|
- redisTemplate.setKeySerializer(stringSerializer);
|
|
|
- redisTemplate.setValueSerializer(stringSerializer);
|
|
|
- redisTemplate.setHashKeySerializer(stringSerializer);
|
|
|
- redisTemplate.setHashValueSerializer(stringSerializer);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- redisTemplate.afterPropertiesSet();
|
|
|
- return redisTemplate;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|