blob: 023772a9e37a89ad5cb3df99fd9975fdf5d36837 [file] [log] [blame]
wuchimedes18addec2025-04-03 17:59:02 +08001package com.example.g8backend.config;
2
3import org.springframework.context.annotation.Bean;
4import org.springframework.context.annotation.Configuration;
5import org.springframework.data.redis.connection.RedisConnectionFactory;
6import org.springframework.data.redis.core.RedisTemplate;
7import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
8import org.springframework.data.redis.serializer.StringRedisSerializer;
9
10@Configuration
11public class RedisConfig {
12
13 @Bean
14 public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
15 RedisTemplate<String, Object> template = new RedisTemplate<>();
16 template.setConnectionFactory(connectionFactory);
17 template.setKeySerializer(new StringRedisSerializer());
18 template.setValueSerializer(new StringRedisSerializer());
19 return template;
20 }
21}