|
@@ -0,0 +1,84 @@
|
|
|
+package com.txz.mall.configurer;
|
|
|
+
|
|
|
+import org.redisson.Redisson;
|
|
|
+import org.redisson.api.RedissonClient;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+
|
|
|
+
|
|
|
+import org.redisson.config.Config;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+
|
|
|
+
|
|
|
+@Configuration
|
|
|
+public class RedissonConfig {
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.address}")
|
|
|
+ private String address;
|
|
|
+
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.password}")
|
|
|
+ private String password;
|
|
|
+
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.database}")
|
|
|
+ private Integer database;
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.connectionMinimumIdleSize}")
|
|
|
+ private Integer connectionMinimumIdleSize;
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.idleConnectionTimeout}")
|
|
|
+ private Integer idleConnectionTimeout;
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.connectTimeout}")
|
|
|
+ private Integer connectTimeout;
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.timeout}")
|
|
|
+ private Integer timeout;
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.retryAttempts}")
|
|
|
+ private Integer retryAttempts;
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.retryInterval}")
|
|
|
+ private Integer retryInterval;
|
|
|
+
|
|
|
+
|
|
|
+ @Value("${redisson.singleServerConfig.connectionPoolSize}")
|
|
|
+ private Integer connectionPoolSize;
|
|
|
+
|
|
|
+// @Value("${redisson.singleServerConfig.reconnectionTimeout}")
|
|
|
+// private Integer reconnectionTimeout;
|
|
|
+//
|
|
|
+// @Value("${redisson.singleServerConfig.failedAttempts}")
|
|
|
+// private Integer failedAttempts;
|
|
|
+
|
|
|
+// redisson.singleServerConfig.database=0 # 默认数据库为0
|
|
|
+// redisson.singleServerConfig.connectionMinimumIdleSize=10 # 连接池中的最小空闲连接数
|
|
|
+// redisson.singleServerConfig.idleConnectionTimeout=10000 # 连接空闲超时,单位:毫秒
|
|
|
+// redisson.singleServerConfig.connectTimeout=10000 # 超时时间,单位:毫秒
|
|
|
+// redisson.singleServerConfig.timeout=3000 # 命令等待超时,单位:毫秒
|
|
|
+// redisson.singleServerConfig.retryAttempts=3 # 命令失败重试次数
|
|
|
+// redisson.singleServerConfig.retryInterval=1500 # 命令重试发送时间间隔,单位:毫秒
|
|
|
+// redisson.singleServerConfig.reconnectionTimeout=3000 # 重新连接时间间隔,单位:毫秒
|
|
|
+// redisson.singleServerConfig.failedAttempts=3 # 在这个时间内失败几次则认为连接失败,单位:次
|
|
|
+ @Bean(destroyMethod = "shutdown")
|
|
|
+ public RedissonClient redisson() {
|
|
|
+ Config config = new Config();
|
|
|
+ config.useSingleServer()
|
|
|
+ .setAddress(address)
|
|
|
+ .setDatabase(database)
|
|
|
+ .setPassword(password)
|
|
|
+ .setConnectionMinimumIdleSize(connectionMinimumIdleSize)
|
|
|
+ .setIdleConnectionTimeout(idleConnectionTimeout)
|
|
|
+ .setConnectTimeout(connectTimeout)
|
|
|
+ .setConnectionPoolSize(connectionPoolSize)
|
|
|
+ .setTimeout(timeout)
|
|
|
+ .setRetryAttempts(retryAttempts)
|
|
|
+ .setRetryInterval(retryInterval)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ;
|
|
|
+ return Redisson.create(config);
|
|
|
+ }
|
|
|
+}
|