Linux 软件免费装
Banner图

Yac Object Cache

开发者 laruence
更新时间 2026年9月15日 12:42
PHP版本: 7.0 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

cache performance object cache yac shared memory

下载

1.2.2 1.3.0 1.3.1

详情介绍:

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 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.

安装:

  1. 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
  1. 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

屏幕截图:

  • Tools → Yac Object Cache: the status bar, with the live shared-memory round trip.
  • Tools → Yac Object Cache: cache status — hit rate, hits and misses over Today / Yesterday / Last 7 days, with the capacity diagnosis on hover.
  • Tools → Yac Object Cache: shared memory contents — keys-by-group pie, occupancy totals and the largest (or hottest) entries, each clickable for the entry inspector.

常见问题:

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, 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.

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.

更新日志:

1.3.1 1.3.0 1.2.2 1.2.1 1.2.0 1.1.1 1.1.0 1.0.0