当前位置:网站首页>007_Redis_Jedis连接池
007_Redis_Jedis连接池
2022-04-23 02:02:00 【_yummy_】
007_redis_Jedis连接池
1、Jedis本身是线程不安全的,并且频繁的创建以及销毁连接会对性能造成损耗。如何解决?
- 我们可以使用Jedis连接池代替Jedis直接连接的方式
2、创建一个Jedis连接池工具类
package com.ym.jedis.util;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/** * @author: LYM * @description Jedis连接池 * @version: V1.0 * @date: 2022/4/20 22:04 */
public class JedisConnectionFactory {
private static final JedisPool jedisPool;
static {
//配置连接池
JedisPoolConfig jedisPoolConfig=new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(8);
jedisPoolConfig.setMaxIdle(8);
jedisPoolConfig.setMinIdle(0);
jedisPoolConfig.setMaxWaitMillis(1000);//最多等待1000ms
//创建连接池对象
jedisPool=new JedisPool(jedisPoolConfig,"10.223.31.215",6379,1000);
}
public static Jedis getJedisPool() {
return jedisPool.getResource();
}
}
3、修改测试类的连接方式


版权声明
本文为[_yummy_]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_43890515/article/details/124308928
边栏推荐
- 有哪些业务会用到物理服务器?
- 2022第六季完美童模 IPA国民赛领跑元宇宙赛道
- 如何设置电脑ip?
- 【动手学深度学习V2】循环神经网络-1.序列模型
- Challenges often faced by client project management
- The sixth season of 2022, the perfect children's model IPA national race leads the yuanuniverse track
- How to call out services in idea and display the startup class in services
- Longest common subsequence (record path version)
- Leetcode40 - total number of combinations II
- Basic knowledge of software testing, you can meet the interviewer after reading it
猜你喜欢

What should I pay attention to when using proxy IP?

Leetcode 112 Total path (2022.04.22)

拨号服务器是什么,有什么用处?

使用代理IP是需要注意什么?

How to initialize "naming and surname" in C language

Virtual serial port function of j-link V9 using skills

2022 crane driver (limited to bridge crane) examination question bank and online simulation examination

用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)

Problem solving: dpkg DEB: error: package name has characters that are't lowercase alphanums or '- +‘

Thinkphp内核开发盲盒商城源码v2.0 对接易支付/阿里云短信/七牛云存储
随机推荐
World Book Day 𞓜 a good book that technicians should not miss (it cutting-edge technology)
使用代理IP是需要注意什么?
OJ daily practice - Finish
What should I pay attention to when using proxy IP?
What code needs unit testing?
J-Link RTT使用
PID refinement
Communication summary between MCU and 4G module (EC20)
批处理多个文件合成一个HEX
Chinese scientists reveal a new mechanism for breaking through the bottleneck of rice yield
Quel est le fichier makefile?
What is an API interface?
Basic knowledge of software testing, you can meet the interviewer after reading it
用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
Leetcode 112 Total path (2022.04.22)
How to classify proxy IP?
What categories do you need to know before using proxy IP?
世界读书日 | 技术人不要错过的好书(IT前沿技术)
揭秘被Arm编译器所隐藏的浮点运算
[hands on learning] network depth v2.1 Sequence model