Finding your next read
Practical craft for people building for the web.
Explore DevelopmentFinding your next read
THE FINDERPRESS TOOL DIRECTORY
Explore this tool and check the official listing for its latest features and requirements.
01 / SOURCE DETAILS
Yac keeps the cache in a shared memory segment accessible to all PHP workers, so a read is a hash lookup in local memory — no cache server, no socket, no network. Highlights Fast. No socket, no network, no global lock, so throughput scales with workers. Yac’s own benchmark measured 13x-70x higher ops/s than APCu and 170x-730x higher than local Memcached, depending on value size. On the author’s own site ( www.laruence.com ) that translated to page renders coming out 19% faster than with the Memcached drop-in. Nothing to operate. No cache server to install, secure, monitor or restart. Health you can read. Hit rate, hits and misses charted over Today / Yesterday / Last 7 days, with a diagnosis that also says when not to add memory. Fails soft. No extension, or yac.enable=0 , degrades to a per-request cache and the site keeps serving. Best fit Single-node or few-node installs where all PHP workers share a machine. For multi-server clusters needing cross-node consistency, a network cache (Memcached/Redis) suits better.
02 / SOURCE DETAILS
Install the Yac extension, any of three ways (then enable extension=yac.so in php.ini): PECL pecl install yac PIE (the PHP Foundation’s PECL successor; yac is on Packagist) pie install laruence/yac Or from source: download the latest release , unzip it, then inside: phpize && ./configure && make && make install Install and activate Yac Object Cache. Activation deploys wp-content/object-cache.php . That is it — no wp-config edit needed. Visit Tools → Yac Object Cache to verify status. Optional php.ini tuning 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 mode
03 / SOURCE DETAILS
Do I need a Memcached or Redis server? No. That is the point — the cache lives in shared memory on the machine. What happens if the Yac extension is not installed? 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. How are keys stored, given Yac’s 48-byte key limit? 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. Does flush() clear other Yac users on the same machine? 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. Multisite? Yes. On multisite the Yac instance prefix is YAC_OCACHE_KEY_PREFIX + the current blog id (ids up to 9999 verbatim, larger ids a 4-hex crc32b digest), and switch_to_blog() re-namespaces: blogs of one install get separate namespaces and never read each other’s entries. The admin page follows the same split — the cache-status totals stay machine-wide, but the shared-memory contents, the group pie and the entry inspector are scoped to (and titled with) the blog you are viewing, so one blog never lists or edits another’s entries. Installs sharing one PHP pool still need different YAC_OCACHE_KEY_PREFIX values. What about wp_cache_flush_group()? 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.
KEEP EXPLORING