简体   繁体   English

清除 Mule 4 中的缓存范围和私有对象存储

[英]Clear the Cache Scope and Private object store in Mule 4

I am building the application in Mule 4 to cache the response from http request component (for 1 hours).我正在 Mule 4 中构建应用程序以缓存来自 http 请求组件的响应(1 小时)。 I use the response to validate the jwt.我使用响应来验证 jwt。 Whenever there is a failure, I need to clear the cache and re-invoke the http request.每当出现故障时,我都需要清除缓存并重新调用 http 请求。 Component used is : Cache Scope使用的组件是:缓存范围

My Current Code looks like below:-我当前的代码如下所示:-

<ee:object-store-caching-strategy name="Caching_Strategy" doc:name="Caching Strategy" doc:id="50e44473-b55a-4bc3-b53a-18e4229a31a3" keyGenerationExpression="#['token']" >
        <os:private-object-store persistent="false" maxEntries="${caching.maxEntries}" entryTtl="${caching.entryTtl}" expirationInterval="${caching.expirationInterval}" />
    </ee:object-store-caching-strategy> 

I don't have any specific requirement to make it private object store but disabling it does not allow me to configure the maxEntries, entryTTL and Expiration Interval.我没有任何特定要求使其成为私有对象存储,但禁用它不允许我配置 maxEntries、entryTTL 和 Expiration Interval。

It would be more helpful if you could guide me the ways to如果你能指导我的方法会更有帮助

  1. clear the cache (could not find any docs mule 4 related to clear the cache)清除缓存(找不到任何与清除缓存相关的文档 mule 4)
  2. how can i keep it as non private object store and define those parameters like entryTtl, maxEntries etc.我如何将其保留为非私有对象存储并定义这些参数,如 entryTtl、maxEntries 等。
  3. when do we need to use the private object stores?我们什么时候需要使用私有对象存储?

I have already tried the exchanges examples for configure the cache ( but there is no mention of clear the cache).我已经尝试过配置缓存的交换示例(但没有提到清除缓存)。

I am using Mule Runtime 4.2.2 and On Prem Mule我正在使用 Mule Runtime 4.2.2 和 On Prem Mule

I have raised a support ticket with Mulesoft and received the below replies我已经向 Mulesoft 提出了支持请求并收到了以下回复

1) Invalidate Cache is shown only in the palette from the Anypoint Studio Version 7.4.1. 1) 无效缓存仅显示在 Anypoint Studio 7.4.1 版的调色板中。 Not shown in earlier version of studio.( I was using 7.3.2)早期版本的工作室中未显示。(我使用的是 7.3.2)

2) They are adding the documentation for the invalidate cache in Mule 4. 2) 他们在 Mule 4 中添加了无效缓存的文档。

3) Usage Note : Cache Scope and the 'Invalidate Cache' processor should share the same Caching_Strategy). 3) 使用注意事项:Cache Scope 和“Invalidate Cache”处理器应该共享相同的 Caching_Strategy)。

4) In order to explicitly define object store and ttl for a Cache Scope, please ensure object store related modules are added to the project. 4)为了明确定义对象存储和缓存范围的ttl,请确保将对象存储相关模块添加到项目中。 This can be done by simply adding a 'Store' processor in your mule flow, this will add all necessary modules to your mule application.这可以通过简单地在您的 mule 流程中添加一个“存储”处理器来完成,这会将所有必要的模块添加到您的 mule 应用程序中。 Then, on the Caching Strategy, General > Reference > Object Store, you can select Edit Inline and define your object store with explicit settings such as - Max entries - Entry ttl - Expiration interval You can remove the unused 'Store' processor as well.然后,在缓存策略中,General > Reference > Object Store,您可以选择 Edit Inline 并使用显式设置定义您的对象存储,例如 - Max entries - Entry ttl - Expiration interval 您也可以删除未使用的“Store”处理器。

Hope it helps others希望它能帮助别人

There is a palette called invalidate cache in the latest Mule versions.在最新的 Mule 版本中有一个名为 invalidate cache 的调色板。 You can simply use it to delete the cache for a cache scope.您可以简单地使用它来删除缓存范围的缓存。

You will require a private object store when you want to persist the key used for caching permanently and also to implement time limits like TTL for a cache.当您想要永久保存用于缓存的密钥并为缓存实现 TTL 等时间限制时,您将需要一个私有对象存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM