perf(2meet-data-optimizer): keep cached routed counts across unrelated post meta writes
- cached counts followed posts' last_changed, which WordPress moves on any post meta write; themes write meta on page views (on dev36 Blocksy saved a dynamic-CSS descriptor for each listing a crawler visited), so the cache was invalidated every few seconds and keyword/filter searches recounted - counts now follow their own last_changed group (tmdo_posts), bumped on clean_post_cache (post saved or deleted; hooked in every mode) and on flat writes through the Hook Bus, plus terms' last_changed; a routed search reads no unmanaged meta - Verify: PostQueryRouterFoundRowsTest (unrelated meta write keeps the count, save or flat write recounts), integration 588, unit 703, phpcs, stan; dev36 front-end - PR: PR-117 (2.3 acceptance)
This commit is contained in:
@@ -434,6 +434,7 @@ 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_last_changed' ) ) { function wp_cache_set_last_changed( $group ) { $GLOBALS['_wp_last_changed'][ $group ] = (string) hrtime( true ); return $GLOBALS['_wp_last_changed'][ $group ]; } }
|
||||
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; } }
|
||||
|
||||
Reference in New Issue
Block a user