@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $compiler |
| 60 | 60 | ->addDebugInfo($this) |
| 61 | - ->write("\$phpfastcacheCacheStrategy".$i." = \$this->env->getExtension('{$extension}')->getCacheStrategy();\n") |
|
| 62 | - ->write("\$phpfastcacheKey".$i." = \$phpfastcacheCacheStrategy".$i."->generateKey(") |
|
| 61 | + ->write("\$phpfastcacheCacheStrategy" . $i . " = \$this->env->getExtension('{$extension}')->getCacheStrategy();\n") |
|
| 62 | + ->write("\$phpfastcacheKey" . $i . " = \$phpfastcacheCacheStrategy" . $i . "->generateKey(") |
|
| 63 | 63 | ->subcompile($this->getNode('annotation')) |
| 64 | 64 | ->raw(", ") |
| 65 | 65 | ->subcompile($this->getNode('key_info')) |
| 66 | 66 | ->write(");\n") |
| 67 | - ->write("\$phpfastcacheCacheBody".$i." = \$phpfastcacheCacheStrategy".$i."->fetchBlock(\$phpfastcacheKey".$i.", \$this->getSourceContext());\n") |
|
| 68 | - ->write("if (\$phpfastcacheCacheBody".$i." === false) {\n") |
|
| 67 | + ->write("\$phpfastcacheCacheBody" . $i . " = \$phpfastcacheCacheStrategy" . $i . "->fetchBlock(\$phpfastcacheKey" . $i . ", \$this->getSourceContext());\n") |
|
| 68 | + ->write("if (\$phpfastcacheCacheBody" . $i . " === false) {\n") |
|
| 69 | 69 | ->indent() |
| 70 | 70 | ->write("\\ob_start();\n") |
| 71 | 71 | ->write("\$compileMc = \\microtime(true);\n") |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | ->outdent() |
| 75 | 75 | ->write("\n") |
| 76 | 76 | // ->write("sleep(2);\n") // For debug purpose |
| 77 | - ->write("\$phpfastcacheCacheBody".$i." = \\ob_get_clean();\n") |
|
| 78 | - ->write("\$phpfastcacheCacheStrategy".$i."->saveBlock(\$phpfastcacheKey".$i.", \$phpfastcacheCacheBody".$i.", \\microtime(true) - \$compileMc, \$this->getSourceContext());\n") |
|
| 77 | + ->write("\$phpfastcacheCacheBody" . $i . " = \\ob_get_clean();\n") |
|
| 78 | + ->write("\$phpfastcacheCacheStrategy" . $i . "->saveBlock(\$phpfastcacheKey" . $i . ", \$phpfastcacheCacheBody" . $i . ", \\microtime(true) - \$compileMc, \$this->getSourceContext());\n") |
|
| 79 | 79 | ->outdent() |
| 80 | 80 | ->write("}\n") |
| 81 | - ->write("echo \$phpfastcacheCacheBody".$i.";\n") |
|
| 81 | + ->write("echo \$phpfastcacheCacheBody" . $i . ";\n") |
|
| 82 | 82 | ; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -72,22 +72,22 @@ discard block |
||
| 72 | 72 | public function fetchBlock($key, \Twig_Source $sourceContext) |
| 73 | 73 | { |
| 74 | 74 | $generationTimeMc = \microtime(true); |
| 75 | - $cacheData = $this->cache->fetch($key[ 'key' ]); |
|
| 75 | + $cacheData = $this->cache->fetch($key['key']); |
|
| 76 | 76 | $generationTime = \microtime(true) - $generationTimeMc; |
| 77 | - $unprefixedKey = \substr($key[ 'key' ], \strlen($this->twigCachePrefix)); |
|
| 77 | + $unprefixedKey = \substr($key['key'], \strlen($this->twigCachePrefix)); |
|
| 78 | 78 | |
| 79 | 79 | if ($this->cacheCollector instanceof CacheCollector) { |
| 80 | 80 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
| 81 | 81 | 'cacheHit' => $cacheData !== null, |
| 82 | - 'cacheTtl' => $key[ 'lifetime' ], |
|
| 83 | - 'cacheSize' => mb_strlen((string)$cacheData), |
|
| 82 | + 'cacheTtl' => $key['lifetime'], |
|
| 83 | + 'cacheSize' => mb_strlen((string) $cacheData), |
|
| 84 | 84 | 'cacheGenTime' => $generationTime, |
| 85 | 85 | 'cacheFileName' => $sourceContext->getName(), |
| 86 | 86 | 'cacheFilePath' => $sourceContext->getPath(), |
| 87 | 87 | ]); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if (!empty($cacheData) && $this->config[ 'twig_block_debug' ]) { |
|
| 90 | + if (!empty($cacheData) && $this->config['twig_block_debug']) { |
|
| 91 | 91 | return "<!-- BEGIN CACHE BLOCK OUTPUT '{$unprefixedKey}' -->\n{$cacheData}\n<!-- // END CACHE BLOCK OUTPUT '{$unprefixedKey}' -->"; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function saveBlock($key, $block, $generationTime, \Twig_Source $sourceContext) |
| 116 | 116 | { |
| 117 | - $unprefixedKey = \substr($key[ 'key' ], \strlen($this->twigCachePrefix)); |
|
| 117 | + $unprefixedKey = \substr($key['key'], \strlen($this->twigCachePrefix)); |
|
| 118 | 118 | |
| 119 | 119 | if ($this->cacheCollector instanceof CacheCollector) { |
| 120 | 120 | $this->cacheCollector->setTwigCacheBlock($unprefixedKey, [ |
| 121 | 121 | 'cacheHit' => false, |
| 122 | - 'cacheTtl' => $key[ 'lifetime' ], |
|
| 123 | - 'cacheSize' => \mb_strlen((string)$block), |
|
| 122 | + 'cacheTtl' => $key['lifetime'], |
|
| 123 | + 'cacheSize' => \mb_strlen((string) $block), |
|
| 124 | 124 | 'cacheGenTime' => $generationTime, |
| 125 | 125 | 'cacheFileName' => $sourceContext->getName(), |
| 126 | 126 | 'cacheFilePath' => $sourceContext->getPath(), |
| 127 | 127 | ]); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - return $this->cache->save($key[ 'key' ], $block, $key[ 'lifetime' ]); |
|
| 130 | + return $this->cache->save($key['key'], $block, $key['lifetime']); |
|
| 131 | 131 | } |
| 132 | 132 | } |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * Xcache and APC cannot coexists |
| 31 | 31 | */ |
| 32 | - try{ |
|
| 32 | + try { |
|
| 33 | 33 | $cache9 = $phpfastcache->get('apccache'); |
| 34 | 34 | $cache10 = $phpfastcache->get('apcucache'); |
| 35 | - }catch(PhpfastcacheDriverCheckException $e){ |
|
| 35 | + } catch (PhpfastcacheDriverCheckException $e) { |
|
| 36 | 36 | $cache11 = $phpfastcache->get('xcachecache'); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | $item8 = $cache7->getItem('test2'); |
| 51 | 51 | $item9 = $cache8->getItem('test2'); |
| 52 | 52 | |
| 53 | - if(isset($cache9) && isset($cache10)) |
|
| 53 | + if (isset($cache9) && isset($cache10)) |
|
| 54 | 54 | { |
| 55 | 55 | $item10 = $cache9->getItem('test2'); |
| 56 | 56 | $item11 = $cache10->getItem('test2'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if(isset($cache11)) |
|
| 59 | + if (isset($cache11)) |
|
| 60 | 60 | { |
| 61 | 61 | $item12 = $cache11->getItem('test2'); |
| 62 | 62 | } |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | $item8->set('Loaded from cache2')->expiresAfter(10); |
| 81 | 81 | $item9->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 82 | 82 | |
| 83 | - if(isset($item10) && isset($item11)) |
|
| 83 | + if (isset($item10) && isset($item11)) |
|
| 84 | 84 | { |
| 85 | 85 | $item10->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 86 | 86 | $item11->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if(isset($item12)) |
|
| 89 | + if (isset($item12)) |
|
| 90 | 90 | { |
| 91 | 91 | $item12->set('Loaded from cache +' . str_repeat('-', rand(1000, 5000)))->expiresAfter(10); |
| 92 | 92 | } |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | $cache7->save($item8); |
| 106 | 106 | $cache8->save($item9); |
| 107 | 107 | |
| 108 | - if(isset($cache9) && isset($cache10)) |
|
| 108 | + if (isset($cache9) && isset($cache10)) |
|
| 109 | 109 | { |
| 110 | 110 | $cache9->save($item10); |
| 111 | 111 | $cache10->save($item11); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - if(isset($cache11)) |
|
| 114 | + if (isset($cache11)) |
|
| 115 | 115 | { |
| 116 | 116 | $cache11->save($item12); |
| 117 | 117 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | // replace this example code with whatever you need |
| 126 | 126 | return $this->render('default/index.html.twig', [ |
| 127 | 127 | 'pfc_test' => $pfc_test, |
| 128 | - 'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'), |
|
| 128 | + 'base_dir' => realpath($this->getParameter('kernel.root_dir') . '/..'), |
|
| 129 | 129 | ]); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | \ No newline at end of file |