当前位置:网站首页>Use of jedispool
Use of jedispool
2022-06-22 05:16:00 【a good idea】
@Bean
public Jedis getJedis() {
Jedis jedis = null;
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(50);
jedisPoolConfig.setMaxIdle(10);
// Set the maximum total number of instances
jedisPoolConfig.setMaxTotal(150);
// Control one pool How many states are there at most idle( Idle ) Of jedis example .
jedisPoolConfig.setMaxIdle(30);
jedisPoolConfig.setMinIdle(10);
// Said when borrow( introduce ) One jedis When an instance , Maximum waiting time , If the wait time is exceeded , And just throw it out JedisConnectionException;
jedisPoolConfig.setMaxWaitMillis(3 * 1000);
// stay borrow One jedis When an instance , In advance or not alidate operation ; If true, Obtained jedis Instances are available ;
jedisPoolConfig.setTestOnBorrow(true);
// In the future pool when , In advance or not validate operation
jedisPoolConfig.setTestOnReturn(true);
jedisPoolConfig.setTestWhileIdle(true);
jedisPoolConfig.setMinEvictableIdleTimeMillis(500);
jedisPoolConfig.setSoftMinEvictableIdleTimeMillis(1000);
jedisPoolConfig.setTimeBetweenEvictionRunsMillis(1000);
jedisPoolConfig.setNumTestsPerEvictionRun(100);
// JedisPool jedisPool = new JedisPool(config, node, port);
JedisPool jedisPool = new JedisPool(jedisPoolConfig, node, port, 5000, password);
try {
// From the connection pool jedis object
jedis = jedisPool.getResource();
return jedis;
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return jedis;
}
边栏推荐
- Monorepo Sliding methodology: Reference module Hot Update
- 北京密云区知识产权贯标的好处,补贴5-10万
- flink部署模式(二)- yarn三种部署模式
- 在Vs Code中搭建JSP开发环境
- postmanUtils工具类,模拟postman的get,post请求
- Graduation feedback! All contributors of Apache Doris community come to receive gifts!
- 冰河十年前的预测如今被阿里实现了,非常震撼
- Accelerate the promotion of industrial Internet, and map out a new blueprint for development
- Service migration when deploying SuperMap iserver war package
- 2022 new test questions for tea specialists (primary) and summary of tea specialists (primary) examination
猜你喜欢

Remote Dictionary Server(Redis)——基于 KV 结构的作为 Cache 使用的 NoSQL 数据库管理系统

laravel的服务容器,服务提供者,门面的理解

Kubernetes——裸机搭建集群环境

Sort ten integers using selection

在Vs Code中搭建JSP开发环境

汉诺塔问题

风阀执行EN 1634-1耐火测试完整性能坚持 4小时吗?

Tupu software 2D and 2.5D case collection | smart Park, data center, SMT production line

Understanding of service container, service provider and facade of laravel

1108. Defanging an IP Address
随机推荐
Idea创建方法时,使用注解提示方法参数(param)、返回值(return)、方法作用(Description)
花式优化器整理
Flink deployment mode (I) - standalone and Application
jedispool工具类
Force buckle 33 [search rotation sort array]
Sort ten integers using selection
从JedisSentinelPool获取jedis
Pull all data of a branch of the code cloud to cover the local code
mysql day04课堂笔记
Contents of 2022 tea master (intermediate) examination and tea master (intermediate) examination
It is easy to analyze and improve R & D efficiency by understanding these five figures
Solutions to MySQL 8.0 public key retrieval is not allowed errors
mysql day03课堂笔记
yarn部署模式依赖预上传设置
Data backup and recovery
CS 611 Game
C语言概念知识扫盲(不定期补充更新)
It's 2022. Don't you hurry to learn typescript?
rambbmitmq推送方
毕业回馈!Apache Doris 社区所有贡献者来领礼品啦!