Skip to content

Commit 085b525

Browse files
committed
minor #15054 [Cache] Adding about marshallers (Nyholm)
This PR was submitted for the 5.x branch but it was squashed and merged into the 5.2 branch instead. Discussion ---------- [Cache] Adding about marshallers This is related to #15050 It will add information about serialisation, encryption and compression. Commits ------- 126cf24 [Cache] Adding about marshallers
2 parents 0688f4c + 126cf24 commit 085b525

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)