Skip to content

[Cache] Added max items and max lifetime options to Array cache #13718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions components/cache/adapters/array_cache_adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ 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.

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

use Symfony\Component\Cache\Adapter\ArrayAdapter;

Expand All @@ -23,5 +20,17 @@ toggles serialization as its second parameter::
$defaultLifetime = 0,

// if ``true``, the values saved in the cache are serialized before storing them
$storeSerialized = true
$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.