File tree Expand file tree Collapse file tree 2 files changed +6
-19
lines changed
DependencyInjection/Compiler Expand file tree Collapse file tree 2 files changed +6
-19
lines changed Original file line number Diff line number Diff line change @@ -27,24 +27,9 @@ class DataCollectorCompilerPass extends BaseCompilerPass
2727 */
2828 protected function prepare ()
2929 {
30- $ this ->transformLoggableCachePools ();
31-
3230 $ collectorDefinition = $ this ->container ->getDefinition ('data_collector.cache ' );
33-
3431 $ serviceIds = $ this ->container ->findTaggedServiceIds ('cache.provider ' );
35- foreach (array_keys ($ serviceIds ) as $ id ) {
36- $ collectorDefinition ->addMethodCall ('addInstance ' , [$ id , new Reference ($ id )]);
37- }
38-
39- $ this ->container ->setDefinition ('data_collector.cache ' , $ collectorDefinition );
40- }
4132
42- /**
43- * Make all cache providers loggable.
44- */
45- private function transformLoggableCachePools ()
46- {
47- $ serviceIds = $ this ->container ->findTaggedServiceIds ('cache.provider ' );
4833 foreach (array_keys ($ serviceIds ) as $ id ) {
4934
5035 // Duplicating definition to $originalServiceId.logged
@@ -56,6 +41,7 @@ private function transformLoggableCachePools()
5641
5742 // Overwrite the original service id with the new LoggingCachePool instance
5843 $ this ->container ->setAlias ($ id , $ id .'.logger ' );
44+ $ collectorDefinition ->addMethodCall ('addInstance ' , [$ id , new Reference ($ id .'.logger ' )]);
5945 }
6046 }
6147}
Original file line number Diff line number Diff line change @@ -63,14 +63,15 @@ public function match($pathInfo)
6363 $ method = strtolower ($ this ->context ->getMethod ());
6464 $ key = 'route_ ' .$ method .'_ ' .$ host .'_ ' .$ pathInfo ;
6565
66- if ($ this ->cachePool ->hasItem ($ key )) {
67- return $ this ->cachePool ->getItem ($ key )->get ();
66+ $ cacheItem = $ this ->cachePool ->getItem ($ key );
67+ if ($ cacheItem ->isHit ()) {
68+ return $ cacheItem ->get ();
6869 }
6970
7071 $ match = parent ::match ($ pathInfo );
71- $ item = $ this ->cachePool ->getItem ($ key );
72- $ item ->set ($ match )
72+ $ cacheItem ->set ($ match )
7373 ->expiresAfter ($ this ->ttl );
74+ $ this ->cachePool ->save ($ cacheItem );
7475
7576 return $ match ;
7677 }
You can’t perform that action at this time.
0 commit comments