feature #IAY66T 增加规则缓存开关配置

This commit is contained in:
DaleLee
2024-12-05 22:57:39 +08:00
parent 78d68f35bf
commit 28685314a8
7 changed files with 37 additions and 7 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -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"
}
]

View File

@@ -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

View File

@@ -1,2 +1,3 @@
liteflow.rule-source=ruleCache/flow.el.xml
liteflow.enable-rule-cache=true
liteflow.rule-cache-capacity=3