当前位置:网站首页>007_ Redis_ Jedis connection pool
007_ Redis_ Jedis connection pool
2022-04-23 02:08:00 【_ yummy_】
007_redis_Jedis Connection pool
1、Jedis Itself is thread unsafe , And frequent connection creation and destruction will cause performance loss . How to solve ?
- We can use Jedis Connection pool instead of Jedis The way of direct connection
2、 Create a Jedis Connection pool tool class
package com.ym.jedis.util;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/** * @author: LYM * @description Jedis Connection pool * @version: V1.0 * @date: 2022/4/20 22:04 */
public class JedisConnectionFactory {
private static final JedisPool jedisPool;
static {
// Configure connection pool
JedisPoolConfig jedisPoolConfig=new JedisPoolConfig();
jedisPoolConfig.setMaxTotal(8);
jedisPoolConfig.setMaxIdle(8);
jedisPoolConfig.setMinIdle(0);
jedisPoolConfig.setMaxWaitMillis(1000);// Waiting for the most 1000ms
// Create connection pool object
jedisPool=new JedisPool(jedisPoolConfig,"10.223.31.215",6379,1000);
}
public static Jedis getJedisPool() {
return jedisPool.getResource();
}
}
3、 Modify the connection method of the test class


版权声明
本文为[_ yummy_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230202506654.html
边栏推荐
- Use Xdebug breakpoint debugging in postman
- PTA: 点赞狂魔
- 010_StringRedisTemplate
- What categories do you need to know before using proxy IP?
- Echo "new password" |passwd -- stdin user name
- Network jitter tool clumsy
- Esp32 message queue using FreeRTOS
- Flink real-time data warehouse project - Design and implementation of DWS layer
- Shardingsphere broadcast table and binding table
- Go language ⌈ mutex and state coordination ⌋
猜你喜欢

Common formatting problems after word writing

校园转转二手市场源码

What categories do you need to know before using proxy IP?

ThinkPHP kernel development blind box mall source code v2 0 docking easy payment / Alibaba cloud SMS / qiniu cloud storage

MySQL C language connection

Redis memory recycling strategy

Micro build low code zero foundation introductory course

What should I pay attention to when using proxy IP?

Find the largest number of two-dimensional arrays

拨号服务器是什么,有什么用处?
随机推荐
Keil MDK Chinese garbled code, two solutions, the font is no longer ugly
002_Redis_String类型常见的操作命令
Why is one plus one equal to two
想体验HomeKit智能家居?不如来看看这款智能生态
A simple and open source navigation website source code
openstack 服务的启动
PTA: praise the crazy devil
有哪些业务会用到物理服务器?
2018 China Collegiate Programming Contest - Guilin Site J. stone game
What business scenarios will the BGP server be used in?
App optimization and advanced scoreboard Part 2 [Mui + flask + mongodb]
搭建网站是用物理机还是云主机好?
[hands on learning] network depth v2.1 Sequence model
Lane cross domain problem
Leetcode46 Full Permutation
Today will finally write system out. Println()
PTA: 点赞狂魔
如何选择一台好的拨号服务器?
They are all intelligent in the whole house. What's the difference between aqara and homekit?
简洁开源的一款导航网站源码