diff --git a/plugin.xml b/plugin.xml
index aac6dc1..5685502 100755
--- a/plugin.xml
+++ b/plugin.xml
@@ -3,12 +3,13 @@
com.fr.solution.plugin.db.redis.v10
yes
- 7.0
+ 7.1
10.0
2019-03-29
richie
[2019-09-18]支持手动选择不同JavaScript脚本引擎。
[2019-09-18]支持连接redis集群。
[2019-08-26]给console增加一个engine()函数,判断使用的脚本引擎名字。
diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java b/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
index 842122f..7da58aa 100644
--- a/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
@@ -85,8 +85,8 @@ public class RedisScriptTableData extends BaseTableData {
long start = System.currentTimeMillis();
ParameterProvider[] ps = getParameters(calculator);
Connection connection = database.get();
- if (connection instanceof NameReference) {
- String name = ((NameReference) connection).getName();
+ String name = RedisUtils.getName(connection);
+ if (StringKit.isNotEmpty(name)) {
RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) {
OrderValue orderValue = dbIndex.get();
diff --git a/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java b/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
index e2393fb..606a2ef 100644
--- a/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
+++ b/src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
@@ -18,7 +18,6 @@ import com.fr.plugin.db.redis.core.order.impl.NumberOrderValue;
import com.fr.plugin.db.redis.util.RedisUtils;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.Calculator;
-import com.fr.stable.NameReference;
import com.fr.stable.ParameterProvider;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
@@ -80,8 +79,8 @@ public class RedisTableData extends BaseTableData {
long start = System.currentTimeMillis();
ParameterProvider[] ps = getParameters(calculator);
Connection connection = database.get();
- if (connection instanceof NameReference) {
- String name = ((NameReference) connection).getName();
+ String name = RedisUtils.getName(connection);
+ if (StringKit.isNotEmpty(name)) {
RedisDatabaseConnection rc = ConnectionKit.getConnection(name, RedisDatabaseConnection.class);
if (rc != null) {
OrderValue orderValue = dbIndex.get();
@@ -98,7 +97,6 @@ public class RedisTableData extends BaseTableData {
}
-
public void readXML(XMLableReader reader) {
super.readXML(reader);
diff --git a/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java b/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java
index 7cff986..5e59809 100644
--- a/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java
+++ b/src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java
@@ -2,11 +2,14 @@ package com.fr.plugin.db.redis.util;
import com.eclipsesource.v8.V8Object;
import com.fanruan.api.util.ArrayKit;
+import com.fanruan.api.util.GeneralKit;
import com.fanruan.api.util.RenderKit;
+import com.fanruan.api.util.StringKit;
import com.fr.plugin.db.redis.help.ScriptBridge;
import com.fr.stable.ParameterProvider;
import redis.clients.jedis.Jedis;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@@ -20,6 +23,7 @@ public class RedisUtils {
/**
* 关闭redis客户端
+ *
* @param jedis redis客户端对象
*/
public static void close(Jedis jedis) {
@@ -49,4 +53,20 @@ public class RedisUtils {
}
}
}
+
+ public static String getName(Object target) {
+ if (target == null) {
+ return StringKit.EMPTY;
+ }
+ try {
+ Method method = target.getClass().getMethod("getName");
+ return GeneralKit.objectToString(method.invoke(target));
+ } catch (NoSuchMethodException e) {
+ return StringKit.EMPTY;
+ } catch (IllegalAccessException e) {
+ return StringKit.EMPTY;
+ } catch (InvocationTargetException e) {
+ return StringKit.EMPTY;
+ }
+ }
}