|
|
|
@@ -1,5 +1,7 @@ |
|
|
|
package com.iformall.config; |
|
|
|
|
|
|
|
import com.iformall.domain.po.PushLimit; |
|
|
|
import com.iformall.domain.po.WxScoreRules; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.cache.CacheManager; |
|
|
|
@@ -10,6 +12,10 @@ import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.data.redis.cache.RedisCacheConfiguration; |
|
|
|
import org.springframework.data.redis.cache.RedisCacheManager; |
|
|
|
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.StringRedisSerializer; |
|
|
|
|
|
|
|
import java.time.Duration; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashSet; |
|
|
|
@@ -68,4 +74,38 @@ public class RedisConfig extends CachingConfigurerSupport { |
|
|
|
return cacheManager; |
|
|
|
} |
|
|
|
|
|
|
|
@Bean("pushLimitRedisTemplate") |
|
|
|
public RedisTemplate<String, PushLimit> getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { |
|
|
|
RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>(); |
|
|
|
|
|
|
|
Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class); |
|
|
|
// value值的序列化 |
|
|
|
template.setValueSerializer(j); |
|
|
|
template.setHashKeySerializer(j); |
|
|
|
|
|
|
|
// key的序列化 |
|
|
|
template.setKeySerializer(new StringRedisSerializer()); |
|
|
|
template.setHashKeySerializer(new StringRedisSerializer()); |
|
|
|
|
|
|
|
template.setConnectionFactory(connectionFactory); |
|
|
|
return template; |
|
|
|
} |
|
|
|
|
|
|
|
@Bean("scoreRuleRedisTemplate") |
|
|
|
public RedisTemplate<String, WxScoreRules> getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { |
|
|
|
RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>(); |
|
|
|
|
|
|
|
Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class); |
|
|
|
// value值的序列化 |
|
|
|
template.setValueSerializer(j); |
|
|
|
template.setHashKeySerializer(j); |
|
|
|
|
|
|
|
// key的序列化 |
|
|
|
template.setKeySerializer(new StringRedisSerializer()); |
|
|
|
template.setHashKeySerializer(new StringRedisSerializer()); |
|
|
|
|
|
|
|
template.setConnectionFactory(connectionFactory); |
|
|
|
return template; |
|
|
|
} |
|
|
|
|
|
|
|
} |