简体   繁体   中英

Mule Cache Scope How to invalidate mule cache for no payload of DB output

We would like to use DB query inside mule cache scope.

Wants to store the output of DB query in cache to save DB query trip.

If the DB query doesn't give any output or payload is empty, we dont want to save in mule cache.

How to invalidate the cache of the empty payload entries ?

thank you.

The answer to this is in mule forum, https://forums.mulesoft.com/questions/84675/mule-cache-scope-how-to-invalidate-mule-cache-for.html

 <ee:cache cachingStrategy-ref="Caching_Strategy" filterExpression="#
   [payload 
      != 'testData']" doc:name="Cache">
         <db:select config-ref="DBConfig" fetchSize="100" 
            doc:name="Database">
             <db:dynamic-query><![CDATA[select * from STUDENT where 
                 student_id = 'TEST']]></db:dynamic-query>
                    </db:select>
                      <choice doc:name="Choice">
                          <when expression="#[message.payload.size() == 0]">
                 <logger message="Payload is empty" level="INFO" 
                   doc:name="Logger"/>
                 <dw:transform-message doc:name="Transform Message">
                     <dw:set-payload><![CDATA[%dw 1.0
                      %output application/json
                        ---
                    payload]]></dw:set-payload>
                 </dw:transform-message>
             </when>
             <otherwise>
                 <object-to-string-transformer doc:name="Object to String"/>
           </otherwise>
       </choice>
       <logger message="After Choice" level="INFO" doc:name="Logger"/>
   </ee:cache>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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