登陆时无法登录
parent
d240697b68
commit
b8eadc7868
@ -0,0 +1,69 @@
|
||||
package com.manage.util;
|
||||
|
||||
|
||||
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
public class JedisPoolUtil {
|
||||
|
||||
private static volatile JedisPool jedisPool = null;
|
||||
// 获得资源包
|
||||
private static Properties properties;
|
||||
|
||||
static {
|
||||
try {
|
||||
properties = PropertiesLoaderUtils.loadAllProperties("redis.properties");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String host = properties.getProperty("redis.host");
|
||||
private static Integer port = Integer.valueOf(properties.getProperty("redis.port"));
|
||||
// private static String auth = properties.getProperty("redis.auth");
|
||||
private static Integer maxTotal = Integer.valueOf(properties.getProperty("redis.maxTotal"));
|
||||
private static Integer maxWait = Integer.valueOf(properties.getProperty("redis.maxWait"));
|
||||
private static Integer timeout = Integer.valueOf(properties.getProperty("redis.timeOut"));
|
||||
private static Integer maxIdle = Integer.valueOf(properties.getProperty("redis.maxIdle"));
|
||||
private static Boolean testOnBorrow = Boolean.valueOf(properties.getProperty("redis.testOnBorrow"));
|
||||
|
||||
private JedisPoolUtil() {};
|
||||
|
||||
public static JedisPool getJedisPoolInstance() {
|
||||
synchronized (JedisPoolUtil.class) {
|
||||
if (jedisPool == null) {
|
||||
JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
poolConfig.setMaxTotal(maxTotal);
|
||||
poolConfig.setMaxIdle(maxIdle);
|
||||
poolConfig.setMaxWaitMillis(maxWait);
|
||||
poolConfig.setTestOnBorrow(testOnBorrow);
|
||||
jedisPool = new JedisPool(poolConfig, host,port,timeout);
|
||||
}
|
||||
}
|
||||
return jedisPool;
|
||||
}
|
||||
|
||||
//释放回池子
|
||||
public static void close(Jedis jedis){
|
||||
if(jedis != null){
|
||||
if (jedis.isConnected()) {
|
||||
try {
|
||||
System.out.println("退出" + jedis.toString() + ":" + jedis.quit());
|
||||
jedis.disconnect();
|
||||
} catch (Exception e) {
|
||||
System.out.println("退出失败");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
##redis\u6570\u636E\u5E93\u7684\u76F8\u5173\u914D\u7F6E
|
||||
##\u8FDE\u63A5\u5730\u5740ip
|
||||
redis.host =localhost
|
||||
##\u7AEF\u53E3\u53F7
|
||||
redis.port = 6379
|
||||
##\u8BBF\u95EE\u5BC6\u7801
|
||||
#redis.auth =JSdocus@702
|
||||
##\u63A7\u5236\u4E00\u4E2Apool\u6700\u591A\u53EF\u4EE5\u6709\u591A\u5C11\u4E2A\u72B6\u6001\u4E3AIdle(\u7A7A)\u7684jedis\u5B9E\u4F8B\u9ED8\u8BA4\u503C\u4E3A8
|
||||
redis.maxIdle = 200
|
||||
##\u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\u5355\u4F4D\u4E3A\u6BEB\u79D2 \u9ED8\u8BA4\u4E3A-1\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\uFF0C\u4E00\u65E6\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\u5219\u76F4\u63A5\u629B\u51FA
|
||||
redis.maxWait = 100000
|
||||
redis.timeOut = 0
|
||||
##\u8BBE\u7F6E\u4E3Atrue\u5219\u4F1A\u5728borrow\u4E00\u4E2Ajedis\u5B9E\u4F8B\u65F6\uFF0C\u63D0\u524D\u505Avalidate\u64CD\u4F5C
|
||||
redis.testOnBorrow =true
|
||||
##\u6700\u5927\u8FDE\u63A5\u6570
|
||||
redis.maxTotal=30
|
Binary file not shown.
After Width: | Height: | Size: 661 KiB |
Loading…
Reference in New Issue