新开分支整理代码:

1.帮助文档修改功能
2.帮助文档与上一版对比功能
3.单点问题解决
4.markdown帮助文档

Conflicts:
	src/main/resources/messages/message_en.properties
	src/main/resources/messages/message_ru.properties
	src/main/resources/messages/message_zh_CN.properties
This commit is contained in:
wangwenrui
2019-01-30 18:17:51 +08:00
committed by 段冬梅
parent 785150f921
commit db00cafd84
654 changed files with 138408 additions and 14 deletions

View File

@@ -0,0 +1,69 @@
package com.nis.util.redis;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.apache.log4j.Logger;
import com.nis.util.Configurations;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class RedisPoolHelper {
private Logger logger=Logger.getLogger(RedisPoolHelper.class);
private JedisPool jedisPool;
private String host;
private int timeout;
public RedisPoolHelper(){
init();
}
private void init() {
synchronized (this) {
if (jedisPool == null) {
host=Configurations.getStringProperty("redis.host", "127.0.0.1:6379");
timeout=Configurations.getIntProperty("redis.timeout", 10000);
String[] hostAndPort = host.split(":");
jedisPool = new JedisPool(getPoolConfig(), hostAndPort[0], Integer.parseInt(hostAndPort[1]), timeout);
logger.info("redis pool init complate! host-->"+hostAndPort[0]+" port:"+Integer.parseInt(hostAndPort[1]));
}
}
}
public Jedis getJedis() {
if (jedisPool == null) {
init();
}
return jedisPool.getResource();
}
public JedisPool getJedisPool() {
return jedisPool;
}
public void setJedisPool(JedisPool jedisPool) {
this.jedisPool = jedisPool;
}
/**
*
* getPoolConfig(初始化连接池的配置,这里可以设置很多参数的,不过目前没加)
* (这里描述这个方法适用条件 可选)
* @return
*GenericObjectPoolConfig
* @exception
* @since 1.0.0
*/
private GenericObjectPoolConfig getPoolConfig(){
GenericObjectPoolConfig config=new GenericObjectPoolConfig();
config.setMaxTotal(Configurations.getIntProperty("redis.pool.maxtotal", 500));//整个池的最大值
config.setMaxIdle(Configurations.getIntProperty("redis.pool.maxidle", 100));//最大空闲
config.setMaxWaitMillis(Configurations.getIntProperty("redis.pool.maxwaitmillis", -1));//获取不到永远等待
config.setBlockWhenExhausted(Configurations.getBooleanProperty("redis.pool.blockwhenexhausted", true));
config.setNumTestsPerEvictionRun(Configurations.getIntProperty("redis.pool.numtestsperevictionrun", Integer.MAX_VALUE));//always test all idle object
config.setTestOnBorrow(Configurations.getBooleanProperty("redis.pool.testonborrow", true));
config.setTestOnReturn(Configurations.getBooleanProperty("redis.pool.testonreturn", false));
config.setTestWhileIdle(Configurations.getBooleanProperty("redis.pool.testwhileidle", true));//发呆过长时间是否先test一下
config.setTimeBetweenEvictionRunsMillis(Configurations.getLongProperty("redis.pool.timebetweenevictionrunsmillis", 60000L));//-1不启动默认1min一次
config.setMinEvictableIdleTimeMillis(Configurations.getLongProperty("redis.pool.minevictableidletimemillis", 60000L));//可发呆的时间10mins
return config;
}
}

View File

@@ -0,0 +1,38 @@
package com.nis.util.redis;
import org.apache.log4j.Logger;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class SaveHelpInfoThread extends Thread {
private Logger logger=Logger.getLogger(SaveHelpInfoThread.class);
private JedisPool jedisPool;
private Jedis jedis;
private String key;
private String value;
private int expire;
public SaveHelpInfoThread(JedisPool jedisPool,String key,String value,int expire){
this.jedisPool=jedisPool;
this.key=key;
this.value=value;
this.expire=expire;
jedis=jedisPool.getResource();
}
@Override
public void run() {
try {
jedis.set(key, value);
if(expire!=-1){
jedis.expire(key, expire);
}
logger.debug("cache help[key --> "+key+"]");
} catch (Exception e) {
logger.error("save redis error",e);
}finally{
jedis.close();
}
}
}