为什么我无法在 MULE4 中缓存变量?



我试图在 mule4 中缓存一个变种。我的简单测试缓存流程是这样的;

<ee:object-store-caching-strategy name="Caching_Strategy" doc:name="Caching Strategy" doc:id="9c17681c-81c3-4344-bd4f-7fda1e36a440">
<os:private-object-store alias="token" persistent="false" entryTtl="100" expirationInterval="5" />
</ee:object-store-caching-strategy>
<ee:cache doc:name="Cache" doc:id="b413ab46-e3e1-4eb0-ac40-0e5884e1438f" cachingStrategy-ref="Caching_Strategy">
<set-variable value="500" doc:name="Set Variable" doc:id="97f4436c-98d3-4993-a4bc-b191282b8f16" variableName="cachevariable"/>
<logger level="INFO" doc:name="Logger" doc:id="0a88f98d-ace9-4326-8d84-31fb7030b75a" message="inside cache"/>
</ee:cache>
<logger level="INFO" doc:name="Logger" doc:id="d92550c2-041f-42ae-b3b5-62ea906ccbb0" message="#[vars.'cachevariable']"/>

在上述场景中,我尝试在第一次调用中缓存一个名为 cachevariable的变量。 我的缓存流命中,缓存范围外的日志打印 500。 在一分钟内的第二次调用中,我得到 Null 表示cachevariable.

为什么?

我将任何点工作室 7.5.1 与运行时 4.1.3 一起使用

我使用了引用对象存储的缓存策略,而不是使用私有存储:

<os:object-store name="customObjectStore" persistent="false" entryTtl="15" expirationInterval="15" expirationIntervalUnit="SECONDS" maxEntries="100"/>
<ee:object-store-caching-strategy  name="Caching_Strategy" doc:name="Caching Strategy" objectStore="customObjectStore" keyGenerationExpression="#[vars.id]" />

此外,我建议始终设置最大条目。

我的例子在我的博客上:https://medium.com/@adobni/configuring-an-object-store-in-mule-4-5da609e3456a

最新更新