繁体   English   中英

Azure API 管理 - 确定响应是否来自缓存

[英]Azure API Management - determine if response was served from cache

我们在<inbound>块中使用<cache-lookup>策略(使用外部 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">可以工作。

对于这个要求,我想你可以在反馈页面上向 azure 开发团队询问这个功能。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM