|
@@ -7,6 +7,7 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import redis.clients.jedis.HostAndPort;
|
|
|
import redis.clients.jedis.JedisCluster;
|
|
|
+import redis.clients.jedis.JedisPoolConfig;
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
import java.util.Set;
|
|
@@ -23,6 +24,14 @@ public class RedisConfig {
|
|
|
|
|
|
@Value("${spring.redis.cluster.nodes}")
|
|
|
private String clusterNodes;
|
|
|
+ @Value("${spring.redis.password}")
|
|
|
+ private String password;
|
|
|
+ @Value("${spring.redis.timeout}")
|
|
|
+ private int timeout;
|
|
|
+ @Value("${spring.redis.jedis.pool.max-idle}")
|
|
|
+ private int maxIdle;
|
|
|
+ @Value("${spring.redis.jedis.pool.max-wait}")
|
|
|
+ private int maxWait;
|
|
|
|
|
|
@Bean
|
|
|
@Singleton
|
|
@@ -41,7 +50,11 @@ public class RedisConfig {
|
|
|
log.error("Redis服务异常!");
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return new JedisCluster(nodes,10000);
|
|
|
+ JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
|
|
+ jedisPoolConfig.setMaxIdle(maxIdle);
|
|
|
+ jedisPoolConfig.setMaxWaitMillis(maxWait);
|
|
|
+
|
|
|
+ return new JedisCluster(nodes,timeout,timeout,4,password, jedisPoolConfig);
|
|
|
}
|
|
|
|
|
|
}
|