2026-04-14 13:19:39 +08:00
|
|
|
package com.label.config;
|
2026-04-09 13:27:47 +08:00
|
|
|
|
|
|
|
|
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.StringRedisSerializer;
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
public class RedisConfig {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory connectionFactory) {
|
|
|
|
|
RedisTemplate<String, String> template = new RedisTemplate<>();
|
|
|
|
|
template.setConnectionFactory(connectionFactory);
|
|
|
|
|
StringRedisSerializer serializer = new StringRedisSerializer();
|
|
|
|
|
template.setKeySerializer(serializer);
|
|
|
|
|
template.setValueSerializer(serializer);
|
|
|
|
|
template.setHashKeySerializer(serializer);
|
|
|
|
|
template.setHashValueSerializer(serializer);
|
|
|
|
|
template.afterPropertiesSet();
|
|
|
|
|
return template;
|
|
|
|
|
}
|
|
|
|
|
}
|