托管商店缓存无法正常工作

时间:2015-06-17 00:08:15

标签: caching mule mule-studio mule-component

我的缓存块永远不会起作用,http请求总是针对相同的值。

    <ee:object-store-caching-strategy name="eventIdCachingStrategy" doc:name="Autobulk EventID Caching Strategy" keyGenerationExpression="#[flowVars['ablMapEventToListingParameters']]">
       <managed-store storeName="${xyz.eventid.cache.store.name}" persistent="true" maxEntries="${xyz.eventid.cache.max.entries}" entryTTL="${xyz.eventid.cache.entry.timetolive}" expirationInterval="${xyz.eventid.cache.expiration.interval}" />
    </ee:object-store-caching-strategy>

    <sub-flow name="mapEventsForListings" doc:name="mapEventsForListings">
        <logger message="Entering mapEventsForListings flow..." level="INFO" doc:name="Logger"/>
        <set-variable variableName="mapEventsForListingsTimeInMillis" value="#[new java.util.Date().getTime()]" doc:name="Set Entry Time In Millis"/> 
        <foreach doc:name="Map Event ID to each listing">
            <choice doc:name="Choice">
               <when expression="#[payload.getEvent().getVenue().isEmpty() || payload.getEvent().getDate().isEmpty() || payload.getExternalListingId().isEmpty() || payload.getPricePerProduct().getAmount()==0]">
                        <logger message="Missing input data for Payload" level="INFO" doc:name="Listing Missing Data Fields"/>
                        <set-variable variableName="noOfIncompleteListings" value="#[noOfIncompleteListings + 1]" doc:name="Increment Incomplete Listings Error Count"/>
                    </when>
                    <otherwise>
                    <set-variable variableName="ablMapEventToListingParameters" value="/?locale=en_US&amp;venueName=#[payload.getEvent().getVenue()]&amp;eventDateLocal=#[payload.getEvent().getDate()]" doc:name="Autobulk Event Search Parameters"/>
                    <set-variable variableName="originalListingRequest" value="#[payload]" doc:name="Variable"/>
                    <set-payload value="#[null]" doc:name="Set Payload"/>
                    <ee:cache doc:name="Cache" cachingStrategy-ref="eventIdCachingStrategy">
                        <https:outbound-endpoint exchange-pattern="request-response" method="GET" connector-ref="HttpsClientConnector" address="${xyz.search.catalog.events.ship.api.url}#[flowVars['ablMapEventToListingParameters']]" contentType="application/json" doc:name="HTTP Outbound Call to BulkCreateListing API">
                            <message-properties-transformer scope="outbound"> 
                                <add-message-property key="TARGET_HOST" value="${target.host}"/>  
                                <add-message-property key="Authorization" value="#[flowVars['shUserBearerToken']]"/>  
                                <add-message-property key="Content-Type" value="application/json"/> 
                            </message-properties-transformer>
                        </https:outbound-endpoint>
                        <echo-component doc:name="Echo"/>
                    </ee:cache>
</otherwise>
</choice>
</flow>

flowVars的价值[&#39; ablMapToListingParameters&#39;] = www.api-dev.xyz.com/search/catalog/events/ship/v3/?locale=en_US&venueName=SAPCenter&eventDateLocal=2015- 07-16T20:00

1 个答案:

答案 0 :(得分:2)

尝试使用以下配置: -

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

此外,您在缓存范围之前将有效负载设置为null ...缓存范围要求有效负载确定是否可以缓存响应。
对于相同的有效负载,它将生成缓存命中并从缓存提供响应,否则它将处理该消息并将其存储在缓存中

参考: - https://docs.mulesoft.com/mule-user-guide/v/3.7/cache-scope