8000 [Cache] Update cache for 4.2 by Nyholm · Pull Request #11391 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Cache] Update cache for 4.2 #11391

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

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixes
  • Loading branch information
Nyholm committed Apr 10, 2019
commit c8d135f8ce53754e88925c8a0d2bbd0f5c48594e
12 changes: 7 additions & 5 deletions components/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Installation

.. include:: /components/require_autoload.rst.inc

.. _cache-psr-6-versus-simple-cache-psr-16:

Cache Contracts versus PSR-6
----------------------------

Expand Down Expand Up @@ -51,7 +53,7 @@ This component includes *two* different approaches to caching:
Cache Contracts
---------------

All adapters supports the Cache Contract. It contains only two methods; ``get`` and
All adapters supports the Cache Contract. It contains only two methods; ``get`` and
``delete``. The first thing you need is to instantiate a cache adapter. The
:class:`Symfony\\Component\\Cache\\Simple\\FilesystemCache` is used in this example::

Expand Down Expand Up @@ -87,10 +89,10 @@ The Cache Contracts also comes with built in `Stampede prevention`_. This will
remove CPU spikes at the moments when the cache is cold. If an example application
spends 5 seconds to compute data that is cached for 1 hour. This data is accessed
10 times every second. This means that you mostly have cache hits and everything
is fine. But after one hour, we get 10 new requests to a cold cache. So we start
to compute that data again. The next second the same thing happens. So we start
to compute that data about 50 times before the cache is warm again. This is where
you need stampede prevention.
is fine. But after one hour, we get 10 new requests to a cold cache. So the data
is computed again. The next second the same thing happens. So the data is computed
about 50 times before the cache is warm again. This is where you need stampede
prevention

The solution is to recompute the value before the cache expires. The algorithm
randomly fakes a cache miss for one user while others still is served the cached
Expand Down
0