当前位置:网站首页>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
边栏推荐
- Hyperscan -- 2 compilation
- 不断下沉的咖啡业,是虚假的繁荣还是破局的前夜?
- Halo open source project learning (I): project launch
- Esp32 message queue using FreeRTOS
- Network jitter tool clumsy
- Today will finally write system out. Println()
- 校园转转二手市场源码
- What are the common proxy IP problems?
- Is CICC fortune a state-owned enterprise and is it safe to open an account
- 一些使用代理IP的小技巧。
猜你喜欢

006_redis_jedis快速入门

arduino esp8266 网络升级 OTA

89 logistic regression user portrait user response prediction

001_redis设置存活时间

Wechat public platform test number application, authorized login function and single sign on using hbuilder X and wechat developer tools

Kubernetes cluster installation based on Kirin SP10 server version

PTA: 点赞狂魔

Analyze the advantages and disadvantages of tunnel proxy IP.

Leetcode39 combined sum

Latin goat (20204-2022) - daily question 1
随机推荐
Arduino esp8266 network upgrade OTA
openstack 服务的启动
How to set computer IP?
Lane cross domain problem
R language advanced | generalized vector and attribute analysis
使用代理IP是需要注意什么?
What is a makefile file?
C standard library - < time h>
代理IP可用率是不是等同于代理IP的效率?
php 2022年4月20面试题整理
007_Redis_Jedis连接池
配置iptables实现本地端口转发的方法详解
OJ daily practice - Finish
从0开始开发一个chrome插件(2)
有哪些常见的代理ip问题?
Is the availability of proxy IP equal to the efficiency of proxy IP?
Tp6 Alibaba Cloud SMS Window message Curl Error 60: SSL Certificate Problem: Unable to get local issuer Certificate
Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘
Is the sinking coffee industry a false prosperity or the eve of a broken situation?
LeetCode 447. Number of boomerangs (permutation and combination problem)