perf(2meet-data-optimizer): flush the cold cache group without a server-side scan
- TMDO_Cache_Layer::flush_group() bumps the post type's cold cache version (option wpdo_cold_cache_version) instead of wp_cache_flush_group(), which Redis Object Cache runs as one server-side scan that blocks Redis on a large group; entries under older keys expire by their TTL - TMDO_Zone_Cold::cache_key() builds every cold blob key; version 0 keeps the current keys, so upgrading invalidates nothing - Verify: CacheLayerTest (new keys, no scan, other post types untouched), unit 702, integration 583, phpcs, stan - PR: PR-110
This commit is contained in:
@@ -197,6 +197,25 @@ class CacheLayerTest extends TestCase {
|
||||
$this->assertNotSame( [ 'stale' => true ], $GLOBALS['_wp_cache'][ $group ][ $cache_key ] ?? null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushing bumps the post type's cache version instead of asking the
|
||||
* object cache to scan the group (a server-side script on Redis that
|
||||
* blocks it on a large group); older entries expire by their TTL.
|
||||
*/
|
||||
public function test_flush_group_moves_to_new_keys_without_a_group_flush(): void {
|
||||
$group = 'wpdo_cold_hp_listing';
|
||||
$old_key = WPDO_Zone_Cold::cache_key( 1, 'hp_listing' );
|
||||
$GLOBALS['_wp_cache'][ $group ][ $old_key ] = array( 'stale' => true );
|
||||
|
||||
WPDO_Cache_Layer::flush_group( 'hp_listing' );
|
||||
|
||||
$new_key = WPDO_Zone_Cold::cache_key( 1, 'hp_listing' );
|
||||
$this->assertNotSame( $old_key, $new_key );
|
||||
$this->assertFalse( wp_cache_get( $new_key, $group ) );
|
||||
$this->assertSame( 'cold_2', WPDO_Zone_Cold::cache_key( 2, 'other_type' ), 'other post types keep their keys' );
|
||||
$this->assertArrayHasKey( $old_key, $GLOBALS['_wp_cache'][ $group ], 'nothing scanned or deleted' );
|
||||
}
|
||||
|
||||
// ── get_stats() ──────────────────────────────────────────────────────────
|
||||
|
||||
public function test_get_stats_includes_required_keys(): void {
|
||||
|
||||
Reference in New Issue
Block a user