简体   繁体   English

如何从Mule获取缓存事件密钥

[英]How to get the Cache Event Key from Mule

I am using Anypoint Studio 6.1 and Mule 3.8.1 and have a mule managed store Caching Strategy that uses the default Event Key generation. 我正在使用Anypoint Studio 6.1和Mule 3.8.1,并且具有使用默认事件密钥生成的Mule托管存储缓存策略。

How can I get the value of this key in a flow? 如何在流程中获取此键的值? Where is it stored? 它存储在哪里?

Thanks 谢谢

By default the generator provides SHA 256 hash as a key if you don't provide a key generator expression in your cache. 默认情况下,如果您在缓存中未提供密钥生成器表达式,则生成器将SHA 256 hash作为密钥提供。
ref:- https://github.com/mulesoft/mule/blob/mule-3.x/core/src/main/java/org/mule/keygenerator/SHA256MuleEventKeyGenerator.java 参考:-https: //github.com/mulesoft/mule/blob/mule-3.x/core/src/main/java/org/mule/keygenerator/SHA256MuleEventKeyGenerator.java
This generators computes a SHA 256 hash of the current message bytes payload. 该生成器计算当前消息字节有效负载的SHA 256 hash

You can use the following example to get the list of cache key of your flow:- 您可以使用以下示例获取流的缓存键列表:-

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

<flow name="keylist" doc:name="keylist">
         <http:listener config-ref="HTTP_Listener_Configuration" path="/getkeyvalue" doc:name="HTTP"/>
            <scripting:component doc:name="Initialise Database"> 
            <scripting:script engine="Groovy">
                <scripting:text><![CDATA[
             def keyValues = [];
              for(a=0;a<muleContext.getRegistry().lookupObject("cachingStrategy").getStore().allKeys().size();a++)
               {
                     keyValues = muleContext.getRegistry().lookupObject("cachingStrategy").getStore().allKeys().get(a);

                }

                if(keyValues.isEmpty())
                {
                 return "Key is either null or expired !!!";
                }
                else
                {
                 return "KeysList " + muleContext.getRegistry().lookupObject("cachingStrategy").getStore().allKeys().toString();
                }           

               ]]></scripting:text>

            </scripting:script>  
        </scripting:component>
       </flow>

Whenever you put some message in your cache, using the above flow you can get all the list of the default cache keys values which the cache scope provide as SHA 256 hash as default 每当您在缓存中添加一些消息时,使用上述流程,您都可以获得默认缓存键值的所有列表,这些默认缓存键值由缓存范围默认提供为SHA 256 hash

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何控制Mule Cache中的密钥生成 - How to control key generation in Mule Cache 如何使Mule的内存中的缓存无效并清除缓存 - How to invalidate and clear cache from in-memory-store in Mule 如何从缓存中获取以某些键开头的所有值 - How to get all values from cache which start with certain key 如何从redis缓存键获取数组值 - how to get array value from redis cache key 如何在 Spring Boot 的 Spring 缓存中按键从缓存中获取单个项目? - How to get individual item by key from cache in Spring cache in Spring Boot? 如何缓存数据库查询结果,并避免无论传入请求如何,缓存都无法处理m子消息? - How to Cache DB Query Result and avoid cache from processing the mule message irrespective of incoming request? 从IRedisClient获取仅缓存缓存命中的键/值映射 - Get key/value mapping of cache only cache hits from IRedisClient rails:如何从 Rails.cache 中获取所有键值 - rails: how to get all key-values from Rails.cache Mule 4 缓存范围。 如何根据特定条件停止 mule 缓存 - Mule 4 Cache Scope. How to stop mule cache for based on certain conditions 一个键怎么可能存在于缓存中,但无法通过 cache.get(key) 检索? - How is it possible that a key exists in cache but cannot be retrieved through cache.get(key)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM