Merge remote-tracking branch 'origin/zhan/fix-RedisUtil' into dev
This commit is contained in:
commit
6821b3a45a
3246
src/main/java/cn/axzo/pokonyan/config/redis/RedisClient.java
Normal file
3246
src/main/java/cn/axzo/pokonyan/config/redis/RedisClient.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
package cn.axzo.pokonyan.config.redis;
|
package cn.axzo.pokonyan.config.redis;
|
||||||
|
|
||||||
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Primary;
|
import org.springframework.context.annotation.Primary;
|
||||||
@ -14,10 +15,17 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|||||||
public class RedisConfiguration {
|
public class RedisConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "axzo.redis.client", name = "type", havingValue = "special", matchIfMissing = true)
|
||||||
public RedisUtil redisUtil(){
|
public RedisUtil redisUtil(){
|
||||||
return new RedisUtil();
|
return new RedisUtil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty(prefix = "axzo.redis.client", name = "type", havingValue = "normal", matchIfMissing = true)
|
||||||
|
public RedisClient redisClient() {
|
||||||
|
return new RedisClient();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisSerializer<String> redisKeySerializer() {
|
public RedisSerializer<String> redisKeySerializer() {
|
||||||
return new StringRedisSerializer();
|
return new StringRedisSerializer();
|
||||||
|
|||||||
@ -28,10 +28,12 @@ import java.util.Map.Entry;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 序列化方式会导致缓存string时增加双引号
|
||||||
* @author JustryDeng
|
* @author JustryDeng
|
||||||
* @date 2020/3/7 16:54:25
|
* @date 2020/3/7 16:54:25
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@Deprecated
|
||||||
public class RedisUtil implements InitializingBean {
|
public class RedisUtil implements InitializingBean {
|
||||||
|
|
||||||
/** 使用StringRedisTemplate(,其是RedisTemplate的定制化升级) */
|
/** 使用StringRedisTemplate(,其是RedisTemplate的定制化升级) */
|
||||||
@ -41,6 +43,7 @@ public class RedisUtil implements InitializingBean {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
log.info("init RedisUtil, both use genericRedisTemplate and stringRedisTemplate");
|
||||||
RedisUtil.genericRedisTemplate = SpringUtil.getBean("genericRedisTemplate", StringRedisTemplate.class);
|
RedisUtil.genericRedisTemplate = SpringUtil.getBean("genericRedisTemplate", StringRedisTemplate.class);
|
||||||
RedisUtil.stringRedisTemplate = SpringUtil.getBean("stringRedisTemplate", StringRedisTemplate.class);
|
RedisUtil.stringRedisTemplate = SpringUtil.getBean("stringRedisTemplate", StringRedisTemplate.class);
|
||||||
genericRedisTemplate.setValueSerializer(new GenericFastJsonRedisSerializer(){
|
genericRedisTemplate.setValueSerializer(new GenericFastJsonRedisSerializer(){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user