Skip to content
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
15 changes: 13 additions & 2 deletions components/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,27 @@ Symfony uses *marshallers* (classes which implement
the cache items before storing them.

The :class:`Symfony\\Component\\Cache\\Marshaller\\DefaultMarshaller` uses PHP's
``serialize()`` or ``igbinary_serialize()`` if the `Igbinary extension`_ is installed.
There are other *marshallers* that can encrypt or compress the data before storing it::
``serialize()`` function by default, but you can optionally use the ``igbinary_serialize()``
function from the `Igbinary extension`_:

use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\DefaultMarshaller;
use Symfony\Component\Cache\DeflateMarshaller;

$marshaller = new DeflateMarshaller(new DefaultMarshaller());
// you can optionally use the Igbinary extension if you have it installed
// $marshaller = new DeflateMarshaller(new DefaultMarshaller(useIgbinarySerialize: true));

$cache = new RedisAdapter(new \Redis(), 'namespace', 0, $marshaller);

There are other *marshallers* that can encrypt or compress the data before storing it.

.. versionadded:: 7.2

In Symfony versions prior to 7.2, the ``igbinary_serialize()`` function was
used by default when the Igbinary extension was installed. Starting from
Symfony 7.2, you have to enable Igbinary support explicitly.

Advanced Usage
--------------

Expand Down