Skip to content

Commit 8775384

Browse files
committed
minor symfony#12770 [Cache] Expand the docs about the cache chain (javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- [Cache] Expand the docs about the cache chain I asked @nicolas-grekas about the Cache chains and he explained to me lots of nice things about this ... so I think we could improve the docs a bit to mention all this. Commits ------- 1227f8b [Cache] Expand the docs about the cache chain
2 parents df13346 + 1227f8b commit 8775384

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

cache.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,21 @@ and use that when configuring the pool.
397397
Creating a Cache Chain
398398
----------------------
399399

400-
Different cache adapters have different strengths and weaknesses. Some might be really
401-
quick but small and some may be able to contain a lot of data but are quite slow.
402-
To get the best of both worlds you may use a chain of adapters. The idea is to
403-
first look at the quick adapter and then move on to slower adapters. In the worst
404-
case the value needs to be recalculated.
400+
Different cache adapters have different strengths and weaknesses. Some might be
401+
really quick but optimized to store small items and some may be able to contain
402+
a lot of data but are quite slow. To get the best of both worlds you may use a
403+
chain of adapters.
404+
405+
A cache chain combines several cache pools into a single one. When storing an
406+
item in a cache chain, Symfony stores it in all pools sequentially. When
407+
retrieving an item, Symfony tries to get it from the first pool. If it's not
408+
found, it tries the next pools until the item is found or an exception is thrown.
409+
Because of this behavior, it's recommended to define the adapters in the chain
410+
in order from the fastest to the slowest.
411+
412+
If an error happens when storing an item in a pool, Symfony stores it in the
413+
other pools and no exception is thrown. Later, when the item is retrieved,
414+
Symfony stores the item automatically in all the missing pools.
405415

406416
.. configuration-block::
407417

0 commit comments

Comments
 (0)