Mule 缓存 - 过期
Mule Cache - Expiry
如何为 mule 中的缓存条目设置到期时间?我正在为传入请求设置一个基于 keyExpression 的缓存,如下所示:
<ee:object-store-caching-strategy name="UserAuth-CachingStrategy" keyGenerationExpression="#[message.inboundProperties.'authorization']" doc:name="Caching Strategy">
缓存应该命中外部 WS,结果应该缓存 5 分钟。如果我用 TTL 设置一个 'in-memory' 存储,比方说 5 分钟,mule 不会接受这个请求。无论 TTL 中的值如何,mule 总是每 3-4 个请求命中一次实际的外部 ws。如果我没有为 TTL 设置任何值,那么缓存永远不会过期。我如何为 mule 中的 'in-memory' 缓存正确设置缓存?
谢谢
如果您使用的是 ObjectStore ,您可以使用 spring 属性轻松设置如下所示,并将您的缓存策略引用给它:-
http://ricston.com/blog/cache-scope-ehcache/
您还可以按以下方式使用托管商店:-
<ee:object-store-caching-strategy nname="UserAuth-CachingStrategy" keyGenerationExpression="#[message.inboundProperties.'authorization']" doc:name="Caching Strategy">
<managed-store storeName="myNonPersistentManagedObjectStore" maxEntries="-1" entryTTL="20000" expirationInterval="5000"/>
</ee:object-store-caching-strategy>
如何为 mule 中的缓存条目设置到期时间?我正在为传入请求设置一个基于 keyExpression 的缓存,如下所示:
<ee:object-store-caching-strategy name="UserAuth-CachingStrategy" keyGenerationExpression="#[message.inboundProperties.'authorization']" doc:name="Caching Strategy">
缓存应该命中外部 WS,结果应该缓存 5 分钟。如果我用 TTL 设置一个 'in-memory' 存储,比方说 5 分钟,mule 不会接受这个请求。无论 TTL 中的值如何,mule 总是每 3-4 个请求命中一次实际的外部 ws。如果我没有为 TTL 设置任何值,那么缓存永远不会过期。我如何为 mule 中的 'in-memory' 缓存正确设置缓存?
谢谢
如果您使用的是 ObjectStore ,您可以使用 spring 属性轻松设置如下所示,并将您的缓存策略引用给它:- http://ricston.com/blog/cache-scope-ehcache/
您还可以按以下方式使用托管商店:-
<ee:object-store-caching-strategy nname="UserAuth-CachingStrategy" keyGenerationExpression="#[message.inboundProperties.'authorization']" doc:name="Caching Strategy">
<managed-store storeName="myNonPersistentManagedObjectStore" maxEntries="-1" entryTTL="20000" expirationInterval="5000"/>
</ee:object-store-caching-strategy>