Skip to content

[Cache] Show how to configure lifetime for app.cache #11365

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

Merged
merged 1 commit into from
Apr 9, 2019
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: 14 additions & 1 deletion cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ For advanced configurations it could sometimes be useful to use a pool as an ada
# config/packages/cache.yaml
framework:
cache:
app: my_configured_app_cache
pools:
my_cache_pool:
adapter: cache.adapter.memcached
Expand All @@ -260,6 +261,10 @@ For advanced configurations it could sometimes be useful to use a pool as an ada
cache.long_cache:
adapter: my_cache_pool
default_lifetime: 604800
my_configured_app_cache:
# "cache.adapter.filesystem" is the default for "cache.app"
adapter: cache.adapter.filesystem
default_lifetime: 3600

.. code-block:: xml

Expand All @@ -272,10 +277,12 @@ For advanced configurations it could sometimes be useful to use a pool as an ada
https://symfony.com/schema/dic/services/services-1.0.xsd">

<framework:config>
<framework:cache>
<framework:cache app="my_cache_pool">
<framework:pool name="my_cache_pool" adapter="cache.adapter.memcached" provider="memcached://user:password@example.com"/>
<framework:pool name="cache.short_cache" adapter="my_cache_pool" default_lifetime="604800"/>
<framework:pool name="cache.long_cache" adapter="my_cache_pool" default_lifetime="604800"/>
<!-- "cache.adapter.filesystem" is the default for "cache.app" -->
<framework:pool name="my_configured_app_cache" adapter="cache.adapter.filesystem" default_lifetime="3600"/>
</framework:cache>
</framework:config>
</container>
Expand All @@ -285,6 +292,7 @@ For advanced configurations it could sometimes be useful to use a pool as an ada
// config/packages/cache.php
$container->loadFromExtension('framework', [
'cache' => [
'app' => 'my_configured_app_cache',
'pools' => [
'my_cache_pool' => [
'adapter' => 'cache.adapter.memcached',
Expand All @@ -298,6 +306,11 @@ For advanced configurations it could sometimes be useful to use a pool as an ada
'adapter' => 'cache.adapter.memcached',
'default_lifetime' => 604800,
],
'my_configured_app_cache' => [
// "cache.adapter.filesystem" is the default for "cache.app"
'adapter' => 'cache.adapter.filesystem',
'default_lifetime' => 3600,
],
],
],
]);
Expand Down