Array Cache Adapter

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 [getValues()](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Cache/Adapter/ArrayAdapter.php "Symfony\Component\Cache\Adapter\ArrayAdapter::getValues()") method.

This adapter can be passed a default cache lifetime as its first parameter, and a boolean that toggles serialization as its second parameter:

  1. use Symfony\Component\Cache\Adapter\ArrayAdapter;
  2. $cache = new ArrayAdapter(
  3. // the default lifetime (in seconds) for cache items that do not define their
  4. // own lifetime, with a value 0 causing items to be stored indefinitely (i.e.
  5. // until the current PHP process finishes)
  6. $defaultLifetime = 0,
  7. // if ``true``, the values saved in the cache are serialized before storing them
  8. $storeSerialized = true
  9. );

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.