我已经使用默认密钥生成过程配置了缓存范围。在缓存范围内,它缓存访问令牌我将此缓存逻辑保存在单独的流中。
例如:
<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 调用时,我在不同的场景中调用上面的缓存流(以获取访问令牌(。 在这里,我的问题是,每次缓存范围的有效负载都不同。因此,它进行新调用以获取新令牌,并且正在缓存更多令牌。如果有效负载相同,则缓存返回相同的令牌。
我的要求是,不要依赖有效载荷。只需返回缓存的访问令牌 8 小时(缓存周期( 如何为此配置缓存键?
使用 keyGenerationExpression 属性为缓存定义自定义键。
例:
keyGenerationExpression="#[vars.requestId]"