Skip to content

TwistedAndy/apcu-object-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Fast APCu Object Cache

Fast APCu Object Cache is a high-performance, lightweight APCu object cache built for large-scale WordPress and WooCommerce projects. It acts as a highly optimized drop-in replacement for the native WordPress in-memory runtime cache, minimizing database load and maximizing execution speed through persistent backend storage.

Features

1. High-Performance APCu Integration

  • Natively leverages the PHP apcu_ extension for ultra-fast, persistent object caching.
  • Reduces heavy database queries by reliably maintaining options, transients, and object metadata in memory.
  • Safely handles APCu memory exhaustion by gracefully deleting keys when storage fails, forcing fresh database reads instead of serving stale data.

2. Dual-Layer Caching Engine

  • Implements an internal runtime cache array to prevent redundant APCu round-trips during a single page load.
  • Automatically trims the runtime cache limit using an efficient, key-preserving slice mechanism to prevent memory exhaustion and array key corruption on massive bulk operations.
  • Strictly adheres to functional and procedural paradigms native to WordPress core.

3. Advanced Group Management

  • Fully supports global cache groups for shared data across networks.
  • Natively handles non-persistent groups (such as counts and plugins) by enforcing that they remain exclusively in the runtime cache and never hit APCu.

4. Multisite & Context Compatibility

  • Provides full WordPress Multisite support.
  • Automatically isolates cache keys using the blog ID prefix to prevent data bleeding across the network.
  • Context-aware key prefixing ensures CLI, Cron, and web requests all target the identical caching environment.

5. Safe Cache Flushing & Iteration

  • Utilizes native APCUIterator objects directly for safe, hash-pointer-accurate group flushing without skipping items.
  • Flushes only the keys belonging to the specific WordPress installation using dynamic key salts, preventing conflicts with other applications or sites running on the same server.

Installation

  • Install the APCu PHP extension on your web server.
  • Copy the object-cache.php file directly into your wp-content/ directory.
  • WordPress will automatically detect the drop-in and initialize the persistent cache.

Configuration

All configuration is automatic, but you can explicitly define your cache salt in wp-config.php to guarantee prefix consistency across different execution environments (like WP-CLI).

About

Author: Andrii Toniievych

Contact: toniyevych@gmail.com

Feel free to contact me if you have any questions.

Contribution

  • Fork this repository
  • Commit your changes
  • Push it to the branch
  • Create the new pull request

License

Twee is released under the MIT Public License.

Note: The "About" section in README.md and the author (@author) notice in the file-headers shall not be edited or deleted without permission. Thank you!

About

A high-performance, lightweight APCu object cache for WordPress and WooCommerce

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages