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