Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb9b57f9

Browse files
[FrameworkBundle] Default to Apcu+Filesystem cache chain
1 parent209fb45 commitb9b57f9

File tree

10 files changed

+49
-43
lines changed

10 files changed

+49
-43
lines changed

‎UPGRADE-3.1.md‎

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,8 @@ FrameworkBundle
9393
cache service. If you are using`serializer.mapping.cache.apc`, use
9494
`serializer.mapping.cache.doctrine.apc` instead.
9595

96-
* The`framework.serializer.cache` option has been deprecated. Configure the
97-
`cache.serializer` service under`framework.cache.pools` instead.
98-
99-
Before:
100-
101-
```yaml
102-
framework:
103-
serializer:
104-
cache:serializer.mapping.cache.apc
105-
```
106-
107-
After:
108-
109-
```yaml
110-
framework:
111-
cache:
112-
pools:
113-
cache.serializer:
114-
adapter:cache.adapter.apcu
96+
* The`framework.serializer.cache` option has been deprecated. APCu should now
97+
be automatically used when available so you can remove this configuration key.
11598

11699
HttpKernel
117100
----------

‎UPGRADE-4.0.md‎

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,8 @@ FrameworkBundle
8080
* The service`serializer.mapping.cache.apc` has been removed; use
8181
`serializer.mapping.cache.doctrine.apc` instead.
8282

83-
* The`framework.serializer.cache` option has been removed. Configure the
84-
`cache.serializer` service under`framework.cache.pools` instead.
85-
86-
Before:
87-
88-
```yaml
89-
framework:
90-
serializer:
91-
cache:serializer.mapping.cache.apc
92-
```
93-
94-
After:
95-
96-
```yaml
97-
framework:
98-
cache:
99-
pools:
100-
cache.serializer:
101-
adapter:cache.adapter.apcu
102-
```
83+
* The`framework.serializer.cache` option has been removed. APCu should now
84+
be automatically used when available so you can remove this configuration key.
10385

10486
HttpKernel
10587
----------

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ private function addCacheSection(ArrayNodeDefinition $rootNode)
564564
->end()
565565
->scalarNode('system')
566566
->info('System related cache pools configuration')
567-
->defaultValue('cache.adapter.filesystem')
567+
->defaultValue('cache.adapter.system')
568568
->end()
569569
->scalarNode('directory')->defaultValue('%kernel.cache_dir%/pools')->end()
570570
->scalarNode('default_doctrine_provider')->end()

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
10391039
{
10401040
$nonce =substr(str_replace('/','-',base64_encode(md5(uniqid(mt_rand(),true),true))),0, -2);
10411041
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2,$nonce);
1042+
$container->getDefinition('cache.adapter.system')->replaceArgument(2,$nonce);
10421043
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2,$config['directory']);
10431044

10441045
foreach (array('doctrine','psr6','redis')as$name) {

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/cache.xml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<tagname="cache.pool" />
1111
</service>
1212

13-
<serviceid="cache.system"parent="cache.adapter.filesystem">
13+
<serviceid="cache.system"parent="cache.adapter.system">
1414
<tagname="cache.pool" />
1515
</service>
1616

@@ -22,6 +22,17 @@
2222
<tagname="cache.pool" />
2323
</service>
2424

25+
<serviceid="cache.adapter.system"class="Symfony\Component\Cache\Adapter\AdapterInterface"abstract="true">
26+
<factoryclass="Symfony\Component\Cache\Adapter\AbstractAdapter"method="createSystemCache" />
27+
<tagname="cache.pool"clearer="cache.default_clearer" />
28+
<tagname="monolog.logger"channel="cache" />
29+
<argument /><!-- namespace-->
30+
<argument /><!-- default lifetime-->
31+
<argument /><!-- nonce-->
32+
<argument>%kernel.cache_dir%/pools</argument>
33+
<argumenttype="service"id="logger"on-invalid="ignore" />
34+
</service>
35+
2536
<serviceid="cache.adapter.apcu"class="Symfony\Component\Cache\Adapter\ApcuAdapter"abstract="true">
2637
<tagname="cache.pool"clearer="cache.default_clearer" />
2738
<tagname="monolog.logger"channel="cache" />

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ protected static function getBundleDefaultConfig()
269269
'cache' =>array(
270270
'pools' =>array(),
271271
'app' =>'cache.adapter.filesystem',
272-
'system' =>'cache.adapter.filesystem',
272+
'system' =>'cache.adapter.system',
273273
'directory' =>'%kernel.cache_dir%/pools',
274274
'default_redis_provider' =>'redis://localhost',
275275
),

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
useSymfony\Bundle\FrameworkBundle\Tests\TestCase;
1515
useSymfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
1616
useSymfony\Component\Cache\Adapter\ApcuAdapter;
17+
useSymfony\Component\Cache\Adapter\ChainAdapter;
1718
useSymfony\Component\Cache\Adapter\DoctrineAdapter;
1819
useSymfony\Component\Cache\Adapter\FilesystemAdapter;
1920
useSymfony\Component\Cache\Adapter\ProxyAdapter;
@@ -728,6 +729,9 @@ private function assertCachePoolServiceDefinitionIsCreated(ContainerBuilder $con
728729
$this->assertSame(DoctrineAdapter::class,$parentDefinition->getClass());
729730
break;
730731
case'cache.app':
732+
if (ChainAdapter::class ===$parentDefinition->getClass()) {
733+
break;
734+
}
731735
case'cache.adapter.filesystem':
732736
$this->assertSame(FilesystemAdapter::class,$parentDefinition->getClass());
733737
break;

‎src/Symfony/Bundle/FrameworkBundle/composer.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"phpdocumentor/reflection-docblock":"<3.0"
5959
},
6060
"suggest": {
61+
"ext-apcu":"For best performance of the system caches",
6162
"symfony/console":"For using the console commands",
6263
"symfony/form":"For using forms",
6364
"symfony/serializer":"For using the serializer service",

‎src/Symfony/Component/Cache/Adapter/AbstractAdapter.php‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
usePsr\Cache\CacheItemInterface;
1515
usePsr\Log\LoggerAwareInterface;
1616
usePsr\Log\LoggerAwareTrait;
17+
usePsr\Log\LoggerInterface;
1718
useSymfony\Component\Cache\CacheItem;
1819

1920
/**
@@ -67,6 +68,24 @@ function ($deferred, $namespace, &$expiredIds) {
6768
);
6869
}
6970

71+
publicstaticfunctioncreateSystemCache($namespace,$defaultLifetime,$nonce,$directory,LoggerInterface$logger =null)
72+
{
73+
$fs =newFilesystemAdapter($namespace,$defaultLifetime,$directory);
74+
if (null !==$logger) {
75+
$fs->setLogger($logger);
76+
}
77+
if (!ApcuAdapter::isSupported()) {
78+
return$fs;
79+
}
80+
81+
$apcu =newApcuAdapter($namespace,$defaultLifetime /5,$nonce);
82+
if (null !==$logger) {
83+
$apcu->setLogger($logger);
84+
}
85+
86+
returnnewChainAdapter(array($apcu,$fs));
87+
}
88+
7089
/**
7190
* Fetches several cache items.
7291
*

‎src/Symfony/Component/Cache/Adapter/ApcuAdapter.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
*/
2020
class ApcuAdapterextends AbstractAdapter
2121
{
22+
publicstaticfunctionisSupported()
23+
{
24+
returnfunction_exists('apcu_fetch') &&ini_get('apc.enabled') && !('cli' ===PHP_SAPI && !ini_get('apc.enable_cli'));
25+
}
26+
2227
publicfunction__construct($namespace ='',$defaultLifetime =0,$nonce =null)
2328
{
24-
if (!function_exists('apcu_fetch') || !ini_get('apc.enabled') || ('cli' ===PHP_SAPI && !ini_get('apc.enable_cli'))) {
29+
if (!static::isSupported()) {
2530
thrownewCacheException('APCu is not enabled');
2631
}
2732
if ('cli' ===PHP_SAPI) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp