标签:ini stat ram password 最小 redis 说明 空闲 conf
对于redis没有设置密码情况,直接去掉类中的密码即可
package com.practice.utils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import java.util.ResourceBundle;
/**
@since 1.0.0
*/
public class JedisPoolUtils {
/** 定义最大空闲数 */
private static int MAX_IDLE;
/** 定义最小空闲数 */
private static int MIN_IDLE;
/** 定义最大连接数 */
private static int MAX_TOTAL;
/** 定义远程IP地址 */
private static String URL;
/** 定义连接端口号 */
private static int PORT;
/** 定义redis客户端登录密码 */
private static String PASSWORD;
/** 定义连接超时时间 */
private static int TIME_OUT;
/** 创建JedisPool对象,定义为空,等待初始化 */
private static JedisPool pool = null;
@return
*/
private static JedisPoolConfig init() {
//读取并加载初始化参数
ResourceBundle bundle = ResourceBundle.getBundle("redis");
MAX_IDLE = Integer.valueOf(bundle.getObject("redis.maxIdle").toString());
MIN_IDLE = Integer.valueOf(bundle.getObject("redis.minIdle").toString());
MAX_TOTAL = Integer.valueOf(bundle.getObject("redis.maxTotal").toString());
URL = bundle.getString("redis.url");
PORT = Integer.valueOf(bundle.getObject("redis.port").toString());
PASSWORD = bundle.getString("redis.password");
TIME_OUT = Integer.valueOf(bundle.getObject("redis.timeOut").toString());
//创建连接池配置对象
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(MAX_IDLE);
poolConfig.setMinIdle(MIN_IDLE);
poolConfig.setMaxTotal(MAX_TOTAL);
return poolConfig;
}
}
标签:ini stat ram password 最小 redis 说明 空闲 conf
原文地址:https://www.cnblogs.com/jay8576/p/9550122.html