wp_cache是否仍然加载WordPress并使用MySQL?

我有一个JSON API端点,它使用wp_cache_set / wp_cache_get来存储结果.这个端点在一天内被击中数十万次.
然而,这通常会占用我的服务器,因为看起来缓存仍在访问MySQL和/或加载Wordpress.
这是真的?如果是这样,什么是更好的缓存解决方案,使尽可能轻的? (例如memcached)
–
这是代码,以防有用:
define('WP_USE_THEMES', false);
require_once('../../../wp-blog-header.php');
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
if(!$image_url) $image_url = $_GET['url'];
if(!$image_url) return false;
$cacheTitle = md5($image_url) . '1';
$result = wp_cache_get( $cacheTitle );
$notCached = $result ? false : true;
if ($notCached){
/** Insert code here to get the data I need and store it in $result **/
wp_cache_set( $cacheTitle, $result );
}
return json_encode($result);
解决方法:
我最终使用Cloudflare页面规则来缓存该特定URL.干净又简单:)