|
@@ -0,0 +1,29 @@
|
|
|
+package com.sw.config;
|
|
|
+
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.data.redis.serializer.RedisSerializer;
|
|
|
+import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|
|
+
|
|
|
+
|
|
|
+ * @author yegang
|
|
|
+ * @create 2022-02-18 10:30
|
|
|
+ **/
|
|
|
+@Configuration
|
|
|
+public class RedisConfig {
|
|
|
+ @Bean
|
|
|
+ public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory factory){
|
|
|
+ RedisTemplate<String, String> redisTemplate = new RedisTemplate<String,String>();
|
|
|
+ redisTemplate.setConnectionFactory(factory);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ RedisSerializer<String> redisSerializer = new StringRedisSerializer();
|
|
|
+ redisTemplate.setKeySerializer(redisSerializer);
|
|
|
+ redisTemplate.setHashKeySerializer(redisSerializer);
|
|
|
+ return redisTemplate;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|