Mule 缓存范围如何在没有 DB 输出有效负载的情况下使 mule 缓存失效 [英] Mule Cache Scope How to invalidate mule cache for no payload of DB output

查看:32
本文介绍了Mule 缓存范围如何在没有 DB 输出有效负载的情况下使 mule 缓存失效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想在 mule 缓存范围内使用 DB 查询.

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

希望将DB查询的输出存储在缓存中以节省DB查询行程.

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

如果数据库查询没有给出任何输出或有效负载为空,我们不想保存在 mule 缓存中.

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 ?

谢谢.

推荐答案

这个问题的答案在 mule 论坛,https://forums.mulesoft.com/questions/84675/mule-cache-scope-how-to-invalidate-mule-cache-for.html

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>

这篇关于Mule 缓存范围如何在没有 DB 输出有效负载的情况下使 mule 缓存失效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆