mirror of
https://github.com/symfony/symfony-docs.git
synced 2026-03-24 00:32:14 +01:00
33 lines
1.3 KiB
ReStructuredText
33 lines
1.3 KiB
ReStructuredText
Array Cache Adapter
|
|
===================
|
|
|
|
Generally, this adapter is useful for testing purposes, as its contents are stored in memory
|
|
and not persisted outside the running PHP process in any way. It can also be useful while
|
|
warming up caches, due to the :method:`Symfony\\Component\\Cache\\Adapter\\ArrayAdapter::getValues`
|
|
method::
|
|
|
|
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
|
|
|
$cache = new ArrayAdapter(
|
|
|
|
// 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 current PHP process finishes)
|
|
$defaultLifetime = 0,
|
|
|
|
// if ``true``, the values saved in the cache are serialized before storing them
|
|
$storeSerialized = true,
|
|
|
|
// the maximum lifetime (in seconds) of the entire cache (after this time, the
|
|
// entire cache is deleted to avoid stale data from consuming memory)
|
|
$maxLifetime = 0,
|
|
|
|
// the maximum number of items that can be stored in the cache. When the limit
|
|
// is reached, cache follows the LRU model (least recently used items are deleted)
|
|
$maxItems = 0
|
|
);
|
|
|
|
.. versionadded:: 5.1
|
|
|
|
The ``maxLifetime`` and ``maxItems`` options were introduced in Symfony 5.1.
|