APCu Cache AdapterEdit this page
Warning: You are browsing the documentation for Symfony 5.0, which is no longer maintained.
Read the updated version of this page for Symfony 6.3 (the current stable version).
This adapter is a high-performance, shared memory cache. It can significantly increase an application's performance, as its cache contents are stored in shared memory, a component appreciably faster than many others, such as the filesystem.
Requirement: The APCu extension must be installed and active to use this adapter.
The ApcuAdapter can optionally be provided a namespace, default cache lifetime, and cache items version string as constructor arguments:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use Symfony\Component\Cache\Adapter\ApcuAdapter; $cache = new ApcuAdapter( // a string prefixed to the keys of the items stored in this cache $namespace = '', // the default lifetime (in seconds) for cache items that do not define their // own lifetime, with a value 0 causing items to be stored indefinitely (i.e. // until the APCu memory is cleared) $defaultLifetime = 0, // when set, all keys prefixed by $namespace can be invalidated by changing // this $version string $version = null );
Use of this adapter is discouraged in write/delete heavy workloads, as these operations cause memory fragmentation that results in significantly degraded performance.
This adapter's CRUD operations are specific to the PHP SAPI it is running under. This means cache operations (such as additions, deletions, etc) using the CLI will not be available under the FPM or CGI SAPIs.