Skip to content

Commit 126cf24

Browse files
Nyholmjaviereguiluz
authored andcommitted
[Cache] Adding about marshallers
1 parent 0688f4c commit 126cf24

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

components/cache.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,25 @@ Now you can create, retrieve, update and delete items using this cache pool::
192192

193193
For a list of all of the supported adapters, see :doc:`/components/cache/cache_pools`.
194194

195+
Serializing Data
196+
----------------
197+
198+
When an item is stored in the cache, it is serialised to a string. It is a class
199+
implementing :class:`Symfony\\Component\\Cache\\Marshaller\\MarshallerInterface`
200+
that is responsible for serializing and unserializing. Or to be technically correct:
201+
to ``marshall()`` and to ``unmarshall()``.
202+
203+
The :class:`Symfony\\Component\\Cache\\Marshaller\\DefaultMarshaller` is using PHP's
204+
``serialize()`` or ``igbinary_serialize()`` if the Igbinary extension is installed.
205+
There are other marshallers that will encrypt or compress the data before storing it::
206+
207+
use Symfony\Component\Cache\Adapter\RedisAdapter;
208+
use Symfony\Component\Cache\DefaultMarshaller;
209+
use Symfony\Component\Cache\DeflateMarshaller;
210+
211+
$marshaller = new DeflateMarshaller(new DefaultMarshaller());
212+
$cache = new RedisAdapter(new \Redis(), 'namespace', 0, $marshaller);
213+
195214
Advanced Usage
196215
--------------
197216

0 commit comments

Comments
 (0)