1414 * @author Khoa Bui (khoaofgod) <khoaofgod@gmail.com> http://www.phpfastcache.com
1515 *
1616 */
17+ declare (strict_types=1 );
1718
1819namespace Phpfastcache \Bundle \Twig \CacheExtension \CacheStrategy ;
1920
@@ -68,19 +69,21 @@ public function __construct(CacheProviderInterface $cache, CacheCollector $cache
6869 /**
6970 * {@inheritDoc}
7071 */
71- public function fetchBlock ($ key )
72+ public function fetchBlock ($ key, \ Twig_Source $ sourceContext )
7273 {
73- $ generationTimeMc = microtime (true );
74+ $ generationTimeMc = \ microtime (true );
7475 $ cacheData = $ this ->cache ->fetch ($ key [ 'key ' ]);
75- $ generationTime = microtime (true ) - $ generationTimeMc ;
76- $ unprefixedKey = substr ($ key [ 'key ' ], strlen ($ this ->twigCachePrefix ));
76+ $ generationTime = \ microtime (true ) - $ generationTimeMc ;
77+ $ unprefixedKey = \ substr ($ key [ 'key ' ], \ strlen ($ this ->twigCachePrefix ));
7778
7879 if ($ this ->cacheCollector instanceof CacheCollector) {
7980 $ this ->cacheCollector ->setTwigCacheBlock ($ unprefixedKey , [
8081 'cacheHit ' => $ cacheData !== null ,
8182 'cacheTtl ' => $ key [ 'lifetime ' ],
8283 'cacheSize ' => mb_strlen ((string )$ cacheData ),
8384 'cacheGenTime ' => $ generationTime ,
85+ 'cacheFileName ' => $ sourceContext ->getName (),
86+ 'cacheFilePath ' => $ sourceContext ->getPath (),
8487 ]);
8588 }
8689
@@ -109,7 +112,7 @@ public function generateKey($annotation, $value)
109112 /**
110113 * {@inheritDoc}
111114 */
112- public function saveBlock ($ key , $ block , $ generationTime )
115+ public function saveBlock ($ key , $ block , $ generationTime, \ Twig_Source $ sourceContext )
113116 {
114117 $ unprefixedKey = \substr ($ key [ 'key ' ], \strlen ($ this ->twigCachePrefix ));
115118
@@ -119,6 +122,8 @@ public function saveBlock($key, $block, $generationTime)
119122 'cacheTtl ' => $ key [ 'lifetime ' ],
120123 'cacheSize ' => \mb_strlen ((string )$ block ),
121124 'cacheGenTime ' => $ generationTime ,
125+ 'cacheFileName ' => $ sourceContext ->getName (),
126+ 'cacheFilePath ' => $ sourceContext ->getPath (),
122127 ]);
123128 }
124129
0 commit comments