perf(2meet-data-optimizer-hivepress-addon): keep HivePress transients a day in the object cache

- MAX_CACHE_TTL: a week -> a day (HivePress's own default); a timeout still
  outlives its value by a minute
- dev36 (1.3M listings): 4.7M entries / 1 GB in the shared Redis at a week,
  evicting other sites' keys
- Verify: composer test (148), integration (53), phpcs clean on the file
- PR: PR-120
This commit is contained in:
2026-09-27 23:26:08 +08:00
parent 0cd2a9db5b
commit 15bbf335f4
2 changed files with 6 additions and 3 deletions
@@ -80,8 +80,8 @@ final class TMDO_Hivepress_Transient_Filter {
/** Object cache group used instead of wp_options when a persistent cache is present. */
public const CACHE_GROUP = 'tmdo_hp_transient';
/** Longest an object-cache entry lives: a week (HivePress's default is a day). */
public const MAX_CACHE_TTL = 604800;
/** Longest an object-cache entry lives: a day, HivePress's own default (2.4 PR-120). */
public const MAX_CACHE_TTL = DAY_IN_SECONDS;
/**
* Register the four metadata filters on `init`. Idempotent — safe to call
@@ -215,11 +215,14 @@ class HivepressTransientFilterTest extends TestCase {
/**
* Entries expire in the object cache too (2.3 PR-099): the value (written
* first, before its timeout is known) after a week, the timeout after the
* first, before its timeout is known) after a day, the timeout after the
* later of that and its own time, plus a minute. Orphans of deleted posts
* no longer pile up.
*/
public function test_with_an_object_cache_entries_get_a_ttl(): void {
// A day, HivePress's own default: at a week, 1.3M listings kept 4.7M
// entries (1 GB) in a shared Redis and pushed other sites' keys out (2.4 PR-120).
$this->assertSame( 86400, WPDO_Hivepress_Transient_Filter::MAX_CACHE_TTL );
$GLOBALS['_wp_using_ext_object_cache'] = true;
$key = '_transient_hp_models/cat/v1';
$translated = WPDO_Hivepress_Transient_Filter::translate_key( 100, $key );