You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
894 B
36 lines
894 B
package com.fr.plugin.db.redis.help; |
|
|
|
import com.eclipsesource.v8.V8; |
|
import com.fr.plugin.db.redis.core.emb.Redis; |
|
import com.fr.plugin.db.redis.help.client.RedisNashornClient; |
|
import com.fr.plugin.db.redis.help.client.RedisV8Client; |
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-08-26 |
|
*/ |
|
public class RedisClientSelector { |
|
|
|
private final static boolean SUPPORT_J2V8 = isSupportJ2v8(); |
|
|
|
public static boolean isSupportJ2v8() { |
|
V8 v8; |
|
try { |
|
v8 = V8.createV8Runtime(); |
|
} catch (IllegalStateException ex) { |
|
return false; |
|
} |
|
v8.release(); |
|
return true; |
|
} |
|
|
|
public static RedisClient select(Redis redis) { |
|
if (SUPPORT_J2V8) { |
|
return new RedisV8Client(redis.getClient()); |
|
} else { |
|
return new RedisNashornClient(redis.getClient()); |
|
} |
|
} |
|
|
|
}
|
|
|