package com.example.redis_java.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import java.time.Duration;
@Configuration
public class JedisConfig {
/**
* jedis连接池
*
* @param jedisProperties
* @return
*/
@Bean
public JedisPool jedisPool(JedisProperties jedisProperties) {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(jedisProperties.getMaxTotall());
config.setMaxIdle(jedisProperties.getMaxIdle());
config.setMinIdle(jedisProperties.getMinIdle());
config.setMaxWait(Duration.ofMillis(jedisProperties.getMaxWaitMillis()));
// config.setMaxWaitMillis(jedisProperties.getMaxWaitMillis());
config.setTestOnBorrow(jedisProperties.isTestOnBorrow());
config.setTestOnReturn(jedisProperties.isTestOnReturn());
config.setTimeBetweenEvictionRuns(Duration.ofMillis(jedisProperties.getTimeBetweenEvictionRunsMillis()));
// config.setTimeBetweenEvictionRunsMillis(jedisProperties.getTimeBetweenEvictionRunsMillis());
config.setTestWhileIdle(jedisProperties.isTestWhileIdle());
config.setNumTestsPerEvictionRun(jedisProperties.getNumTestsPerEvictionRun());
if (StringUtils.hasText(jedisProperties.getPassword())) {
return new JedisPool(config, jedisProperties.getHost(), jedisProperties.getPort(), jedisProperties.getTimeout(), jedisProperties.getPassword());
}
return new JedisPool(config, jedisProperties.getHost(), jedisProperties.getPort(), jedisProperties.getTimeout());
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
资源介绍请参考: https://blog.csdn.net/TRXCXS/article/details/136412070?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22136412070%22%2C%22source%22%3A%22TRXCXS%22%7D
资源推荐
资源详情
资源评论
收起资源包目录
Redis_Java.zip (27个子文件)
HELP.md 430B
mvnw.cmd 7KB
pom.xml 2KB
src
test
java
com
example
redis_java
LettureTest.java 1KB
JedisTest.java 773B
RedisJavaApplicationTests.java 226B
main
resources
application.yml 723B
java
com
example
redis_java
RedisJavaApplication.java 333B
config
JedisProperties.java 743B
JedisConfig.java 2KB
.mvn
wrapper
maven-wrapper.properties 233B
maven-wrapper.jar 61KB
.idea
jarRepositories.xml 864B
workspace.xml 5KB
misc.xml 607B
compiler.xml 781B
.gitignore 190B
encodings.xml 191B
target
classes
application.yml 723B
com
example
redis_java
RedisJavaApplication.class 760B
config
JedisProperties.class 3KB
JedisConfig.class 2KB
test-classes
com
example
redis_java
LettureTest.class 2KB
RedisJavaApplicationTests.class 558B
JedisTest.class 1KB
generated-test-sources
test-annotations
generated-sources
annotations
mvnw 11KB
.gitignore 395B
共 27 条
- 1
资源评论
TRXCX
- 粉丝: 273
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功