@@ -94,7 +94,7 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
94
94
}
95
95
96
96
/**
97
- * Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise .
97
+ * Returns the best possible adapter that your runtime supports .
98
98
*
99
99
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
100
100
*
@@ -108,16 +108,12 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
108
108
*/
109
109
public static function createSystemCache ($ namespace , $ defaultLifetime , $ version , $ directory , LoggerInterface $ logger = null )
110
110
{
111
- if (null === self ::$ apcuSupported ) {
112
- self ::$ apcuSupported = ApcuAdapter::isSupported ();
111
+ $ opcache = new PhpFilesAdapter ($ namespace , $ defaultLifetime , $ directory , true );
112
+ if (null !== $ logger ) {
113
+ $ opcache ->setLogger ($ logger );
113
114
}
114
115
115
- if (!self ::$ apcuSupported ) {
116
- $ opcache = new PhpFilesAdapter ($ namespace , $ defaultLifetime , $ directory , true );
117
- if (null !== $ logger ) {
118
- $ opcache ->setLogger ($ logger );
119
- }
120
-
116
+ if (!self ::$ apcuSupported = self ::$ apcuSupported ?? ApcuAdapter::isSupported ()) {
121
117
return $ opcache ;
122
118
}
123
119
@@ -128,7 +124,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
128
124
$ apcu ->setLogger ($ logger );
129
125
}
130
126
131
- return $ apcu ;
127
+ return new ChainAdapter ([ $ apcu, $ opcache ]) ;
132
128
}
133
129
134
130
public static function createConnection ($ dsn , array $ options = [])
0 commit comments