diff --git a/plugin.xml b/plugin.xml
index d9ba434..0aa97e9 100755
--- a/plugin.xml
+++ b/plugin.xml
@@ -3,7 +3,7 @@
com.fr.solution.plugin.db.redis.v10
yes
- 5.1
+ 5.2
10.0
2018-11-29
richie
diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java b/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
index 6c931f7..4d86e06 100755
--- a/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/RedisDatabaseConnection.java
@@ -20,11 +20,13 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
private static final int DEFAULT_REDIS_PORT = 6379;
private static final int MAX_TOTAL = 10;
+ private static final int MAX_WAIT = -1;
private Conf host = Holders.simple(StringUtils.EMPTY);
private Conf port = Holders.simple(DEFAULT_REDIS_PORT);
private Conf password = Holders.simple(StringUtils.EMPTY);
private Conf maxTotal = Holders.simple(MAX_TOTAL);
+ private Conf maxWait = Holders.simple(MAX_WAIT);
public RedisDatabaseConnection() {
@@ -62,6 +64,14 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
this.maxTotal.set(maxTotal);
}
+ public int getMaxWait() {
+ return maxWait.get();
+ }
+
+ public void setMaxWait(int maxWait) {
+ this.maxWait.set(maxWait);
+ }
+
@Override
public void testConnection() throws Exception {
Jedis client = createRedisClient();
@@ -77,7 +87,7 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
}
public Jedis createRedisClient() {
- return RedisPool.getPool().getResource(getHost(), getPort(), getPassword(), getMaxTotal());
+ return RedisPool.getPool().getResource(getHost(), getPort(), getPassword(), getMaxTotal(), getMaxWait());
}
@Override
@@ -152,6 +162,7 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
setPassword(SecurityToolbox.encrypt(pwd));
}
setMaxTotal(reader.getAttrAsInt("maxTotal", MAX_TOTAL));
+ setMaxWait(reader.getAttrAsInt("maxWait", MAX_WAIT));
}
}
}
@@ -166,6 +177,7 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
writer.attr("password", SecurityToolbox.decrypt(getPassword()));
}
writer.attr("maxTotal", getMaxTotal());
+ writer.attr("maxWait", getMaxWait());
writer.end();
}
@@ -176,6 +188,7 @@ public class RedisDatabaseConnection extends AbstractDatabaseConnection {
cloned.port = (Conf) port.clone();
cloned.password = (Conf) password.clone();
cloned.maxTotal = (Conf) maxTotal.clone();
+ cloned.maxWait = (Conf) maxWait.clone();
return cloned;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java b/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java
index a12daa9..0cdd3d0 100644
--- a/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/RedisPool.java
@@ -25,16 +25,16 @@ public class RedisPool {
private Map jedisPoolMap = new ConcurrentHashMap();
- public Jedis getResource(String host, int port, String password, int maxTotal) {
+ public Jedis getResource(String host, int port, String password, int maxTotal, int maxWait) {
JedisPool jedisPool = jedisPoolMap.get(host);
if (jedisPool == null) {
- jedisPool = createJedisPool(host, port, password, maxTotal);
+ jedisPool = createJedisPool(host, port, password, maxTotal, maxWait);
jedisPoolMap.put(host, jedisPool);
}
return jedisPool.getResource();
}
- private JedisPool createJedisPool(String host, int port, String password, int maxTotal) {
+ private JedisPool createJedisPool(String host, int port, String password, int maxTotal, int maxWait) {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(maxTotal);
//连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true
@@ -51,7 +51,7 @@ public class RedisPool {
config.setMaxIdle(10);
//最大连接数,可配置
//获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1
- config.setMaxWaitMillis(-1);
+ config.setMaxWaitMillis(maxWait);
//逐出连接的最小空闲时间 默认1800000毫秒(30分钟)
config.setMinEvictableIdleTimeMillis(1800000);
//最小空闲连接数, 默认0
diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableDataModel.java b/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableDataModel.java
index f8f3c09..c673af4 100644
--- a/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableDataModel.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableDataModel.java
@@ -3,6 +3,7 @@ package com.fr.plugin.db.redis.core;
import com.eclipsesource.v8.V8;
import com.eclipsesource.v8.V8Array;
import com.eclipsesource.v8.V8Object;
+import com.fr.base.TableData;
import com.fr.data.AbstractDataModel;
import com.fr.plugin.db.redis.help.Console;
import com.fr.plugin.db.redis.help.Files;
@@ -61,7 +62,8 @@ public class RedisScriptTableDataModel extends AbstractDataModel {
columnNames[i] = String.valueOf(v8Column.get(i));
}
int returnRowCount = v8Table.length();
- for (int i = 0, realCount = Math.min(returnRowCount, this.rowCount); i < realCount; i++) {
+ int realCount = rowCount == TableData.RESULT_ALL ? returnRowCount : Math.min(returnRowCount, this.rowCount);
+ for (int i = 0; i < realCount; i++) {
V8Array v8Row = v8Table.getArray(i);
List