简体   繁体   English

如何使Mule的内存中的缓存无效并清除缓存

[英]How to invalidate and clear cache from in-memory-store in Mule

I have a simple doubt ... I have a in-memory cache configuration as following :- 我有一个简单的疑问……我具有如下的内存中缓存配置:

<ee:object-store-caching-strategy name="cachingStrategy" doc:name="Caching Strategy">
<in-memory-store name="inMem" maxEntries="100" entryTTL="6800" expirationInterval="6800"/>
</ee:object-store-caching-strategy>

The cache is working fine with no issue .. But what I want is to invalidate the cache .. 缓存工作正常,没有问题..但是我要使缓存无效..

I have also created a flow for invalidating all the cache as follow :- 我还创建了一个使所有缓存无效的流程,如下所示:

<flow name="cacheinvalidate" doc:name="cacheinvalidate">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8083/invalidate" doc:name="HTTP"/>
<object-to-string-transformer doc:name="Object to String"/>
<ee:invalidate-cache cachingStrategy-ref="cachingStrategy"/>
<set-payload value="All cache invalidated" doc:name="Set Payload"/>
</flow>

But it's not working in the case of in-memory-store ..... I am getting following exception :- 但这在内存中的情况下是行不通的.....我收到以下异常:-

Message : Cannot not invalidate object store because it not a org.mule.api.store.ListableObjectStore (org.mule.api.cache.InvalidateCacheException). Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Cannot not invalidate object store because it not a org.mule.api.store.ListableObjectStore (org.mule.api.cache.InvalidateCacheException)
com.mulesoft.mule.cache.ObjectStoreCachingStrategy:103 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/cache/InvalidateCacheException.html)
2. Cannot not invalidate object store because it not a org.mule.api.store.ListableObjectStore (org.mule.api.cache.InvalidateCacheException). Message payload is of type: String (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.cache.InvalidateCacheException: Cannot not invalidate object store because it not a org.mule.api.store.ListableObjectStore
at com.mulesoft.mule.cache.ObjectStoreCachingStrategy.invalidate(ObjectStoreCachingStrategy.java:103)
at com.mulesoft.mule.cache.InvalidateCacheMessageProcessor.process(InvalidateCacheMessageProcessor.java:24)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

I guess the invalidation is done by iterating the keys in the cache and deleting the entries, and the cache implementation must be a ListableObjectStore ( like in case of custom object-store ), which seems to be missing in this case for in-memory-store. 我猜想是通过迭代缓存中的键并删除条目来完成的,并且缓存实现必须是ListableObjectStore (例如在自定义对象存储的情况下),在这种情况下,内存中似乎缺少商店。

But I like to know if there any way that I can invalidate and clear all the cache if I use in-memory-store. 但是我想知道如果使用内存存储,是否有任何方法可以使所有缓存无效并清除所有缓存。

Please suggest, how it can be done here in this case of in-memory-store ??? 请提出建议,在这种情况下如何在内存中存储???

Please note that I am using Mule 3.5 and Mule enterprise <ee:cache> 请注意,我正在使用Mule 3.5和Mule企业版<ee:cache>

尝试使用非持久性托管存储。

Yes, the final solution I got is using a non-persistent managed-store :- 是的,我得到的最终解决方案是使用非持久性托管商店:-

<ee:object-store-caching-strategy name="cachingStrategy" doc:name="cachingStrategy">
   <managed-store storeName="myNonPersistentManagedObjectStore" maxEntries="-1" entryTTL="20000" expirationInterval="5000"/>
</ee:object-store-caching-strategy>

We can invalidate the cache in-memory-store by passing invalidate-key as given below: 我们可以通过传递invalidate-key来使内存中的缓存无效,如下所示:

<ee:cache doc:name="Cache" cachingStrategy-ref="Caching_Strategy_Database">
<ee:invalidate-key cachingStrategy-ref="Caching_Strategy_Database"/>

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

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