mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-06-10 03:07:32 +08:00
feature #IAY66T 增加规则缓存开关配置
This commit is contained in:
@@ -101,7 +101,7 @@ public class FlowExecutor {
|
||||
}
|
||||
|
||||
// 规则缓存
|
||||
if (isStart && liteflowConfig.isRuleCacheEnabled()) {
|
||||
if (isStart && liteflowConfig.getEnableRuleCache()) {
|
||||
Integer capacity = liteflowConfig.getRuleCacheCapacity();
|
||||
RuleCacheLifeCycle ruleCacheLifeCycle = new RuleCacheLifeCycle(capacity);
|
||||
LifeCycleHolder.addLifeCycle(ruleCacheLifeCycle);
|
||||
|
||||
@@ -113,6 +113,9 @@ public class LiteflowConfig {
|
||||
//是否启用节点实例ID
|
||||
private Boolean enableNodeInstanceId;
|
||||
|
||||
// 是否启用规则缓存
|
||||
private Boolean enableRuleCache;
|
||||
|
||||
// 规则缓存容量
|
||||
private Integer ruleCacheCapacity;
|
||||
|
||||
@@ -485,6 +488,16 @@ public class LiteflowConfig {
|
||||
this.enableNodeInstanceId = enableNodeInstanceId;
|
||||
}
|
||||
|
||||
public Boolean getEnableRuleCache() {
|
||||
if (ObjectUtil.isNull(enableRuleCache)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return enableRuleCache;
|
||||
}
|
||||
|
||||
public void setEnableRuleCache(Boolean enableRuleCache) {
|
||||
this.enableRuleCache = enableRuleCache;
|
||||
}
|
||||
|
||||
public Integer getRuleCacheCapacity() {
|
||||
return ruleCacheCapacity;
|
||||
@@ -493,8 +506,4 @@ public class LiteflowConfig {
|
||||
public void setRuleCacheCapacity(Integer ruleCacheCapacity) {
|
||||
this.ruleCacheCapacity = ruleCacheCapacity;
|
||||
}
|
||||
|
||||
public boolean isRuleCacheEnabled() {
|
||||
return ObjectUtil.isNotNull(ruleCacheCapacity) && ruleCacheCapacity > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,9 @@ public class LiteflowProperty {
|
||||
//是否启用节点实例ID
|
||||
private boolean enableNodeInstanceId;
|
||||
|
||||
// 是否启用规则缓存
|
||||
private Boolean enableRuleCache;
|
||||
|
||||
// 规则缓存容量
|
||||
private Integer ruleCacheCapacity;
|
||||
|
||||
@@ -341,4 +344,12 @@ public class LiteflowProperty {
|
||||
public void setRuleCacheCapacity(Integer ruleCacheCapacity) {
|
||||
this.ruleCacheCapacity = ruleCacheCapacity;
|
||||
}
|
||||
|
||||
public Boolean isEnableRuleCache() {
|
||||
return enableRuleCache;
|
||||
}
|
||||
|
||||
public void setEnableRuleCache(Boolean enableRuleCache) {
|
||||
this.enableRuleCache = enableRuleCache;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public class LiteflowPropertyAutoConfiguration {
|
||||
liteflowConfig.setGlobalThreadPoolQueueSize(property.getGlobalThreadPoolQueueSize());
|
||||
liteflowConfig.setGlobalThreadPoolSize(property.getGlobalThreadPoolSize());
|
||||
liteflowConfig.setEnableNodeInstanceId(property.isEnableNodeInstanceId());
|
||||
liteflowConfig.setEnableRuleCache(property.isEnableRuleCache());
|
||||
liteflowConfig.setRuleCacheCapacity(property.getRuleCacheCapacity());
|
||||
return liteflowConfig;
|
||||
}
|
||||
|
||||
@@ -208,9 +208,16 @@
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "liteflow.liteflow.rule-cache-capacity",
|
||||
"name": "liteflow.enable-rule-cache",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable rule cache.",
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "liteflow.rule-cache-capacity",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "Set the rules cache capacity.",
|
||||
"description": "Set rule cache capacity.",
|
||||
"sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -24,4 +24,5 @@ liteflow.global-thread-pool-size=16
|
||||
liteflow.global-thread-pool-queue-size=512
|
||||
liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder
|
||||
liteflow.enable-node-instance-id=false
|
||||
liteflow.enable-rule-cache=false
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
liteflow.rule-source=ruleCache/flow.el.xml
|
||||
liteflow.enable-rule-cache=true
|
||||
liteflow.rule-cache-capacity=3
|
||||
Reference in New Issue
Block a user