[英]How to generate cache key in Mule4 for accesstoken?
我已经使用默认密钥生成过程配置了我的缓存 scope。在缓存 scope 中,它缓存了accesstoken这个缓存逻辑我保持在单独的流程中。
例如:
<os:object-store name="Object_store" doc:name="Object store" persistent="false" maxEntries="10" entryTtl="7" entryTtlUnit="HOURS" expirationIntervalUnit="HOURS"/>
<ee:object-store-caching-strategy
name="Caching_Strategy" doc:name="Caching Strategy" objectStore="Object_store" />
<flow name="sys-caching:\tokenFlow">
<ee:cache doc:name="Cache" cachingStrategy-ref="Caching_Strategy">
<flow-ref doc:name="getchallenge" name="sys-authentication:\get-challenge-subflow"/>
<flow-ref doc:name="getaccesstoken"name="sys-authentication:\get-token-subflow"/>
</ee:cache>
</flow>
在使用外部端点进行 GET/POST 调用时,我在不同的场景中调用上述缓存流(以获取访问令牌)。 这里我的问题是,每次缓存 scope 的有效负载都不同。 因此,它会发出新的调用来获取新的令牌,并且会缓存更多的令牌。 如果有效负载相同,则缓存返回相同的令牌。
我的要求是,不依赖于有效负载。 . 只需将缓存的访问令牌返回 8 小时(缓存期)如何为此配置缓存密钥?
使用 keyGenerationExpression 属性为缓存定义自定义键。
例子:
keyGenerationExpression="#[vars.requestId]"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.