| | |
| | | package com.sandu.ximon.admin.config; |
| | | |
| | | import com.sandu.common.config.BaseRedisConfig; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.*; |
| | | import org.springframework.data.redis.serializer.StringRedisSerializer; |
| | | |
| | | /** |
| | | * @author chenjiantian |
| | |
| | | */ |
| | | @Configuration |
| | | public class RedisConfig extends BaseRedisConfig { |
| | | @Autowired |
| | | private RedisConnectionFactory factory; |
| | | |
| | | @Bean |
| | | public RedisTemplate<String, Object> redisTemplate() { |
| | | RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); |
| | | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| | | redisTemplate.setHashKeySerializer(new StringRedisSerializer()); |
| | | redisTemplate.setHashValueSerializer(new StringRedisSerializer()); |
| | | redisTemplate.setValueSerializer(new StringRedisSerializer()); |
| | | redisTemplate.setConnectionFactory(factory); |
| | | return redisTemplate; |
| | | } |
| | | |
| | | @Bean |
| | | public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) { |
| | | return redisTemplate.opsForHash(); |
| | | } |
| | | |
| | | @Bean |
| | | public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) { |
| | | return redisTemplate.opsForValue(); |
| | | } |
| | | |
| | | @Bean |
| | | public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) { |
| | | return redisTemplate.opsForList(); |
| | | } |
| | | |
| | | @Bean |
| | | public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) { |
| | | return redisTemplate.opsForSet(); |
| | | } |
| | | |
| | | @Bean |
| | | public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) { |
| | | return redisTemplate.opsForZSet(); |
| | | } |
| | | } |