diff --git a/liteflow-core/pom.xml b/liteflow-core/pom.xml
index b6da77fe2..5d79cd668 100644
--- a/liteflow-core/pom.xml
+++ b/liteflow-core/pom.xml
@@ -59,5 +59,9 @@
commons-io
commons-io
+
+ com.github.ben-manes.caffeine
+ caffeine
+
diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/cache/RuleCachePostProcessFlowExecuteLifeCycle.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/cache/RuleCachePostProcessFlowExecuteLifeCycle.java
new file mode 100644
index 000000000..f3a607ff8
--- /dev/null
+++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/cache/RuleCachePostProcessFlowExecuteLifeCycle.java
@@ -0,0 +1,67 @@
+package com.yomahub.liteflow.flow.cache;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.RemovalCause;
+import com.github.benmanes.caffeine.cache.RemovalListener;
+import com.yomahub.liteflow.flow.FlowBus;
+import com.yomahub.liteflow.flow.element.Chain;
+import com.yomahub.liteflow.flow.element.Condition;
+import com.yomahub.liteflow.lifecycle.PostProcessFlowExecuteLifeCycle;
+import com.yomahub.liteflow.slot.Slot;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+import java.util.List;
+
+/**
+ * Chain执行前的缓存处理
+ * @author DaleLee
+ * @since
+ */
+public class RuleCachePostProcessFlowExecuteLifeCycle implements PostProcessFlowExecuteLifeCycle {
+ /**
+ * 缓存
+ */
+ private final Cache cache;
+
+ public RuleCachePostProcessFlowExecuteLifeCycle(int capacity) {
+ this.cache = Caffeine.newBuilder()
+ .maximumSize(capacity)
+ .evictionListener(new ChainRemovalListener())
+ .build();
+ }
+
+ @Override
+ public void postProcessBeforeFlowExecute(String chainId, Slot slot) {
+ Chain chain = FlowBus.getChain(chainId);
+ if (ObjectUtil.isNull(chain)) {
+ return;
+ }
+ // 记录在缓存中
+ cache.put(chainId, chain);
+ }
+
+ @Override
+ public void postProcessAfterFlowExecute(String chainId, Slot slot) {
+
+ }
+
+ /**
+ * 监听在缓存中被移除的chain
+ */
+ private static class ChainRemovalListener implements RemovalListener {
+
+ @Override
+ public void onRemoval(@Nullable String chanId, @Nullable Chain chain, @NonNull RemovalCause removalCause) {
+ List conditionList = chain.getConditionList();
+ // 清空condition 并将chain设置为未编译
+ if (CollUtil.isNotEmpty(conditionList)) {
+ conditionList.clear();
+ }
+ chain.setCompiled(false);
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
index 9dc40ddfa..88f203932 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,6 +78,7 @@
3.1.12
1.9.23
1.3.6
+ 2.9.3
@@ -326,6 +327,11 @@
liquor-eval
${liquor.version}
+
+ com.github.ben-manes.caffeine
+ caffeine
+ ${caffeine.version}
+