Browse Source

兼容

paid 7.1
richie 5 years ago
parent
commit
0d61e79d44
  1. 3
      plugin.xml
  2. 4
      src/main/java/com/fr/plugin/db/redis/core/RedisScriptTableData.java
  3. 6
      src/main/java/com/fr/plugin/db/redis/core/RedisTableData.java
  4. 20
      src/main/java/com/fr/plugin/db/redis/util/RedisUtils.java

3
plugin.xml

@ -3,12 +3,13 @@
<id>com.fr.solution.plugin.db.redis.v10</id>
<name><![CDATA[Redis数据集]]></name>
<active>yes</active>
<version>7.0</version>
<version>7.1</version>
<env-version>10.0</env-version>
<jartime>2019-03-29</jartime>
<vendor>richie</vendor>
<description><![CDATA[可以连接Redis数据库,支持哈希表、列表、集合以及有序集合]]></description>
<change-notes><![CDATA[
[2019-09-29]修复无法兼容老版本的问题。<br/>
[2019-09-18]支持手动选择不同JavaScript脚本引擎。<br/>
[2019-09-18]支持连接redis集群。<br/>
[2019-08-26]给console增加一个engine()函数,判断使用的脚本引擎名字。<br/>

4
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();

6
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);

20
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;
}
}
}

Loading…
Cancel
Save