New in Symfony 4.4: Cache Improvements
Allow to use URL DSN in PDO adapters¶
Contributed by
Jérémy Derussé
in #34057.
The PDO cache adapter allows to configure the connection in several ways:
using a PHP PDO object, a Doctrine DBAL Connection, or a Data Source Name (DSN).
In Symfony 4.4, it will also be possible to use a URL DSN. This means for
example that you can reuse the DATABASE_URL
value if you want to:
1 2 3 4 5 6 7 8 9 10 11 12 13 | # config/packages/cache.yaml
framework:
cache:
pools:
cache.app:
adapter: cache.adapter.pdo
provider: app.my_pdo_provider
services:
app.my_pdo_provider:
factory: ['Symfony\Component\Cache\Adapter\PdoAdapter', 'createConnection']
arguments:
- '%env(DATABASE_URL)%'
|
Added new marshallers¶
Contributed by
Nicolas Grekas
in #33939
and #34133.
In computing science, a marshaller transforms the memory representation of an object to a data format suitable for storage or transmission. In Symfony 4.4 we've added two marshallers to the Cache component.
The first one is TagAwareMarshaller
, which optimizes the data storage when
using tag-aware cache adapters. This marshaller is enabled automatically so you
don't have to do anything.
The second one is DeflateMarshaller
, which compresses the contents before
caching them to save space (and uncompresses them automatically later, so the
entire process is transparent to the user).
This marshaller is not enabled by default because that might break cache pools that are shared between different applications. You can enable it via decoration:
1 2 3 4 5 | # config/services.yaml
services:
Symfony\Component\Cache\Marshaller\DeflateMarshaller:
decorates: cache.default_marshaller
arguments: ['@Symfony\Component\Cache\Marshaller\DeflateMarshaller.inner']
|
Faster deletion of cache items¶
Contributed by
Nicolas Grekas
in #33921.
Filesystem based cache adapters use a nested directory structure to store their contents. In Symfony 4.4, we introduced some optimizations to navigate that directory structure much faster when deleting items.
A Blackfire profiling showed a massive performance improvement (up to 100%)
thanks to the removal of thousands of function calls related to
RecursiveDirectoryIterator
.
Simpler configuration of chained cache pools¶
Contributed by
Nicolas Grekas
in #32294.
In Symfony 4.4, defining chained cache pools will be much simpler:
1 2 3 4 5 6 7 8 9 10 | # config/packages/cache.yaml
framework:
cache:
pools:
my_chained_pool:
default_lifetime: 12
adapters:
- cache.adapter.array
- cache.adapter.filesystem
- { name: cache.adapter.redis, provider: 'redis://foo' }
|
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
New in Symfony 4.4: Cache Improvements symfony.com/index.php/blog/new-in-symfony-4-4-cache-improvements
Tweet thisComments
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
Sidi LEKHALIFA said on Nov 7, 2019 at 14:10 #1