perf(2meet-data-optimizer): cache found-rows counts for routed queries
- TMDO_Post_Query_Router drops SQL_CALC_FOUND_ROWS from routed searches (posts_request) and answers found_posts_query from a COUNT(*) of the same query, cached in the object cache under posts' last_changed. - Hook Bus flat post writes and deletes move posts' last_changed: in aeav_only they skip update_metadata()'s own hooks, so query caches would otherwise outlive the write. - Bench (1M): cached page 8 ms (was 694 / 363 ms for scenarios 1 / 2); after invalidation 8 ms + COUNT 608 / 344 ms, on par with before. - REST X-WP-Total COUNT is on the frozen Hot zone path (ADR-003): not changed. - Verify: core unit 659 / integration 475, HP 142/49, WC 10/22 green, phpcs clean - PR: PR-030
This commit is contained in:
@@ -408,6 +408,8 @@ if ( ! function_exists( 'wp_mkdir_p' ) ) {
|
||||
}
|
||||
|
||||
$GLOBALS['_wp_cache'] = [];
|
||||
if ( ! function_exists( 'wp_cache_get_last_changed' ) ) { function wp_cache_get_last_changed( $group ) { return $GLOBALS['_wp_last_changed'][ $group ] ??= '0'; } }
|
||||
if ( ! function_exists( 'wp_cache_set_posts_last_changed' ) ) { function wp_cache_set_posts_last_changed() { $GLOBALS['_wp_last_changed']['posts'] = (string) hrtime( true ); } }
|
||||
if ( ! function_exists( 'wp_cache_get' ) ) { function wp_cache_get( $key, $group = '' ) { return $GLOBALS['_wp_cache'][ $group ][ $key ] ?? false; } }
|
||||
if ( ! function_exists( 'wp_cache_set' ) ) { function wp_cache_set( $key, $value, $group = '', $ttl = 0 ): bool { $GLOBALS['_wp_cache'][ $group ][ $key ] = $value; return true; } }
|
||||
if ( ! function_exists( 'wp_cache_delete' ) ) { function wp_cache_delete( $key, $group = '' ): bool { unset( $GLOBALS['_wp_cache'][ $group ][ $key ] ); return true; } }
|
||||
|
||||
Reference in New Issue
Block a user