问题描述
我们在 <cache-lookup>
块中使用 <inbound>
策略(使用外部 Redis)。是否可以执行策略 - 具体而言,我想在缓存查找命中并且响应从缓存提供时编写 <trace>
?
今天我们有这个:
<inbound>
<cache-lookup vary-by-developer="false" vary-by-developer-groups="false" downstream-caching-type="none" caching-type="external">
<vary-by-query-parameter>xyz</vary-by-query-parameter>
</cache-lookup>
这样的事情可能吗? (伪代码)
<choose>
<when condition="cache-lookup == true">
<trace>
<message>This request is served from Redis cache!</message>
</trace>
</when>
</choose>
</inbound>
解决方法
根据一些研究,我们似乎没有一个变量或状态来判断请求是从 Redis 缓存还是后端服务器提供的。 <cache-lookup>
策略包装了与 Redis 连接的函数,我认为我们无法知道请求是从哪里提供的。正如你提到的代码是伪代码,我不认为代码 <when condition="cache-lookup == true">
可以工作。
对于这个需求,我想你可以在 feedback 页面上向 azure 开发团队询问这个功能。