WP Discourse 正在对 site.json 进行大量请求

是的。
奇怪的是,它应该是缓存的,而且我没有任何理由相信它不是。

$categories = get_transient( 'wpdc_discourse_categories' );
if ( ! empty( $options['publish-category-update'] ) || ! $categories ) {
  $body = $this->discourse_request( '/site.json' );
  if ( is_wp_error( $body ) ) {
    return $body;
  }

  if ( $body->categories ) {

    // removed for brevity

    // Note that setting the cache to 0 will disable transient expiration.
    $category_cache_period = apply_filters( 'wpdc_category_cache_minutes', 10 );
    set_transient( 'wpdc_discourse_categories', $discourse_categories, intval( $category_cache_period ) * MINUTE_IN_SECONDS );

    return $discourse_categories;
  } else {
    return new \WP_Error( 'key_not_found', 'The categories key was not found in the response from Discourse.' );
  }
}

编辑:当我列出瞬态时,我确实有一个键 timeout_wpdc_discourse_categories,其值为 5 分钟后的时间戳,但我没有 wpdc_discourse_categories :thinking:

编辑 2:set_transient( 'wpdc_discourse_categories', $discourse_categories, intval( $category_cache_period ) * MINUTE_IN_SECONDS ); 返回 false。$discourse_categories 已正确填充。其他瞬态正在工作。