| 开发者 | laruence |
|---|---|
| 更新时间 | 2026年9月15日 12:42 |
| PHP版本: | 7.0 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
yac.enable=0, degrades to a per-request cache and the site keeps serving.extension=yac.so in php.ini):phpize && ./configure && make && make install
wp-content/object-cache.php.yac.enable = 1 yac.keys_memory_size = 16M ; ~128K slots (~32K per 4M) yac.values_memory_size = 64M ; raise for large sites (big alloptions)
Optional wp-config switches
define( 'YAC_OCACHE_KEY_PREFIX', 'ab' ); // default wp; give each install its own when sites share one PHP pool define( 'YAC_OCACHE_EMPTY_TTL', 0 ); // default 21600s: lifetime cap on empty negative results; 0 disables define( 'YAC_OCACHE_DISABLE', true ); // escape hatch: force runtime-only modeNo. That is the point — the cache lives in shared memory on the machine.
The drop-in degrades to a per-request cache: the site keeps working, you lose cross-request persistence, and the status page flags the missing extension.
As <YAC_OCACHE_KEY_PREFIX>:<group>:<key> (default prefix wp), verbatim while they fit the 48-byte budget; over-long keys keep the group verbatim and hash (crc32b) only the key part.
Yes. wp_cache_flush() calls Yac::flush(), which wipes the entire shared memory on the machine, including data written by other Yac users sharing the PHP pool. The admin page asks for confirmation first.
Yes, with a caveat: keys carry no per-blog prefix, so blogs of one install share the namespace and switch_to_blog() does not re-namespace. Give each install its own YAC_OCACHE_KEY_PREFIX when sites sharing a PHP pool must not see each other's entries.
Yac cannot delete entries by prefix, so a group flush clears the request-level copy of that group; shared entries then expire via TTL. The plugin reports flush_group as unsupported so core does not rely on it.
wp yac deploy-dropin, wp yac update-dropin, wp yac remove-dropin.WP_Comment_Query::get_comments() wraps an empty result as array('comment_ids' => array(), 'found_comments' => 0)) are now recognized as negative cache results and capped by YAC_OCACHE_EMPTY_TTL instead of occupying a slot forever.WP_CACHE is no longer required or reported. WordPress loads object-cache.php regardless of it — that constant only gates advanced-cache.php (page caching), which this plugin does not provide. The live CI run now boots WordPress without it to prove the point.Yac::dump() instead of accumulating the whole dump.yac.keys_memory_size = 16M (~128K slots); 4M gives only ~32K.wp_cache_set() on a key already written by wp_cache_add() in the same request skipped the shared write, so other requests kept reading the value the add stored (the update_option() pattern left the old option behind).YAC_OCACHE_SKIP_EMPTY with YAC_OCACHE_EMPTY_TTL (default 21600s): empty results now share as usual but expire instead of occupying a slot forever.slots_used high-water mark.pre_wp_cache_get as a core hook.wp_kses_post() strips SVG elements.yac_ocache_/YAC_OCACHE_/yac-ocache- prefixes for WordPress.org policy (wp_ is reserved for core). The wp_cache_* functions and $wp_object_cache keep their standard names; WP-CLI stays wp yac status / wp yac flush.false is now written as 0: Yac's get() returns false for both a miss and a stored false, so a stored false never survived past the request.c_len.Yac::dump() instead of one dump(-1), which could exhaust the memory limit.<prefix>:<group>:<key> with no per-blog prefix; over-long keys hash only the key part.YAC_OCACHE_DISABLE escape hatch forces runtime-only mode.