繁体   English   中英

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

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

我有一个简单的疑问……我具有如下的内存中缓存配置:

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

缓存工作正常,没有问题..但是我要使缓存无效..

我还创建了一个使所有缓存无效的流程,如下所示:

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

但这在内存中的情况下是行不通的.....我收到以下异常:-

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)

我猜想是通过迭代缓存中的键并删除条目来完成的,并且缓存实现必须是ListableObjectStore (例如在自定义对象存储的情况下),在这种情况下,内存中似乎缺少商店。

但是我想知道如果使用内存存储,是否有任何方法可以使所有缓存无效并清除所有缓存。

请提出建议,在这种情况下如何在内存中存储???

请注意,我正在使用Mule 3.5和Mule企业版<ee:cache>

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

是的,我得到的最终解决方案是使用非持久性托管商店:-

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

我们可以通过传递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