Write to me

Software / Maintained

TukuToi APCu Object Cache

A single-file WordPress object-cache drop-in backed by APCu, multisite-aware, with a Cache Stats screen under Tools. Falls back to per-request caching without APCu.

WordPress can keep its object cache in memory between requests if a drop-in provides one. This is that drop-in for servers with the APCu extension: one file, object-cache.php, placed in wp-content. The setup guide pairs it with an NGINX FastCGI page cache.

How it works:

  • APCu when available. Persistence switches on only if the APCu extension is loaded and enabled. Otherwise every call falls back to an in-request cache, so the site keeps working.
  • Isolated keys. Each key combines a salt, a hash of the install path, the site, the group and a version. Two WordPress installs on one server do not see each other’s data.
  • Flushing without scans. Flushing a group or a site bumps its version number instead of walking through keys.
  • Multisite. Site-specific groups are prefixed with the blog ID, global groups are shared, and switch_to_blog() is followed.
  • Cache Stats. A screen under Tools, for administrators only, shows APCu status and version, hits and misses for the request, APCu uptime and memory use.

Two constants tune it: WP_APCU_KEY_SALT and WP_APCU_LOCAL_CACHE (a per-request mirror that saves repeated APCu reads). The implementation was originally inspired by l3rady/object-cache-apcu.

Current state

Version 1.1.1 (January 2026) brought the code in line with the WordPress Coding Standards, hardened the stats screen, fixed replace(), incr()/decr() and multisite flush edge cases, and added architecture and API documentation.