APCu: APC User Cache

APCu is a high-performance, in-memory key-value store for PHP. It provides a robust and simple API for caching and retrieving PHP variables from shared memory, significantly speeding up applications by reducing the load on databases and other backend services.

Keys are strings, and values can be any serializable PHP variable.

Project Background

APCu is a direct descendant of the original Alternative PHP Cache (APC) extension. It has been refactored to remove the opcode caching component, which is now handled by the Zend OPcache extension bundled with PHP. APCu focuses exclusively on providing a fast and efficient userland variable cache.

For projects that previously relied on the apc_* functions, a separate backwards compatibility module is available.

Key Features

  • In-Memory Caching: Stores data in a shared memory segment for extremely fast read and write access across multiple PHP processes.
  • Simple API: Offers an intuitive set of functions for storing, fetching, deleting, and managing cached data.
  • Atomic Operations: Provides atomic increment (apcu_inc) and decrement (apcu_dec) operations, as well as a compare-and-swap (apcu_cas) function.
  • Flexible TTL: Supports both a global Time-To-Live (TTL) for all entries and a per-entry TTL for fine-grained cache control.
  • Advanced Tools: Includes the APCUIterator for efficiently scanning cache entries and a comprehensive monitoring script (apc.php) for observing cache performance and managing its contents.

Ready to get started? Head to the Installation guide.