Skip to content

Commit

Permalink
优化代码,增加redisson配置
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Feb 10, 2022
1 parent 4dc183c commit 9aa7a6d
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 15 deletions.
21 changes: 21 additions & 0 deletions buyer-api/src/main/resources/redisson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: lilishop
subscriptionsPerConnection: 5
clientName: null
address: "redis://pg2481.com:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 24
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.MarshallingCodec> {}
transportMode: "NIO"
21 changes: 21 additions & 0 deletions common-api/src/main/resources/redisson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: lilishop
subscriptionsPerConnection: 5
clientName: null
address: "redis://pg2481.com:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 24
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.MarshallingCodec> {}
transportMode: "NIO"
21 changes: 21 additions & 0 deletions consumer/src/main/resources/redisson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: lilishop
subscriptionsPerConnection: 5
clientName: null
address: "redis://pg2481.com:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 24
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.MarshallingCodec> {}
transportMode: "NIO"
13 changes: 6 additions & 7 deletions framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- Swagger API文档 -->
<!-- https://mvnrepository.com/artifact/org.redisson/redisson-spring-boot-starter -->
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>${redisson}</version>
</dependency>

<dependency>
<groupId>com.github.xiaoymin</groupId>
Expand Down Expand Up @@ -165,12 +170,6 @@
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>${jasypt-version}</version>
</dependency>

<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>${redisson}</version>
</dependency>
<!-- 阿里云核心包-->
<dependency>
<groupId>com.aliyun</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.alibaba.fastjson.parser.ParserConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -17,6 +20,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.cache.RedisCacheWriter;
Expand All @@ -27,6 +31,7 @@
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import java.io.IOException;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -99,6 +104,12 @@ public RedisTemplate<Object, Object> redisTemplate(LettuceConnectionFactory lett
return template;
}

@Bean(destroyMethod = "shutdown")
public RedissonClient redisson() throws IOException {
return Redisson.create(
Config.fromYAML(new ClassPathResource("redisson.yaml").getInputStream()));
}

/**
* 自定义缓存key生成策略,默认将使用该策略
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public static AuthUser getCurrentUser() {
public static String getUuid() {
if (RequestContextHolder.getRequestAttributes() != null) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String uuid = request.getHeader(SecurityEnum.UUID.getValue());
return uuid;
return request.getHeader(SecurityEnum.UUID.getValue());
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package cn.lili.modules.member.token;

import cn.lili.common.context.ThreadContextHolder;
import cn.lili.common.enums.ClientTypeEnum;
import cn.lili.common.properties.RocketmqCustomProperties;
import cn.lili.common.security.AuthUser;
import cn.lili.common.security.enums.UserEnums;
import cn.lili.common.security.token.Token;
import cn.lili.common.security.token.TokenUtil;
import cn.lili.common.security.token.base.AbstractTokenGenerate;
import cn.lili.common.context.ThreadContextHolder;
import cn.lili.common.enums.ClientTypeEnum;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.member.service.MemberService;
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.rocketmq.tags.MemberTagsEnum;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import cn.lili.common.security.token.TokenUtil;
import cn.lili.common.security.token.base.AbstractTokenGenerate;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.member.service.MemberService;
import cn.lili.modules.store.entity.dos.Store;
import cn.lili.modules.store.service.StoreService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
Expand All @@ -31,7 +30,7 @@ public class StoreTokenGenerate extends AbstractTokenGenerate<Member> {

@Override
public Token createToken(Member member, Boolean longTerm) {
if (!member.getHaveStore()) {
if (Boolean.FALSE.equals(member.getHaveStore())) {
throw new ServiceException(ResultCode.STORE_NOT_OPEN);
}
LambdaQueryWrapper<Store> queryWrapper = new LambdaQueryWrapper<>();
Expand Down
21 changes: 21 additions & 0 deletions manager-api/src/main/resources/redisson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: lilishop
subscriptionsPerConnection: 5
clientName: null
address: "redis://pg2481.com:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 24
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.MarshallingCodec> {}
transportMode: "NIO"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<jasypt-version>3.0.4</jasypt-version>
<neetl-version>2.9.10</neetl-version>
<lombok-version>1.18.22</lombok-version>
<redisson>3.5.5</redisson>
<redisson>3.15.6</redisson>
<aliyun-version>4.5.18</aliyun-version>
<aliyun-sdk-oss-version>3.11.1</aliyun-sdk-oss-version>
<aliyun-sdk-dysms-version>2.0.8</aliyun-sdk-dysms-version>
Expand Down
21 changes: 21 additions & 0 deletions seller-api/src/main/resources/redisson.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: lilishop
subscriptionsPerConnection: 5
clientName: null
address: "redis://pg2481.com:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 24
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.MarshallingCodec> {}
transportMode: "NIO"

0 comments on commit 9aa7a6d

Please sign in to comment.