From: Fabien Potencier Date: Thu, 22 Sep 2011 20:04:27 +0000 (+0200) Subject: merged branch runfalk/master (PR #368) X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=0408f0afaffb7b65144bb6dc6a1651db8b9b6205;p=konrad%2Ftwig.git merged branch runfalk/master (PR #368) Commits ------- eb5c9fb Recipe code formatting fix. New recipe for improved APC bytecode support Discussion ---------- APC recipe A new recipe to support cache invalidation when using *APC* with *apc.stat* = 0 and compiled code caching turned on. One sometimes want to test things without restarting apache. This recipe overrides *writeCacheFile* in *Twig_Environment* and calls *apc_compile_file to refresh cache. --- 0408f0afaffb7b65144bb6dc6a1651db8b9b6205 diff --cc doc/recipes.rst index 9701f70,d2e2d23..a9034e1 --- a/doc/recipes.rst +++ b/doc/recipes.rst @@@ -254,6 -253,27 +254,26 @@@ how you can do it: // the $template is valid } catch (Twig_Error_Syntax $e) { // $template contains one or more syntax errors - } + + Refreshing modified templates when APC is switched on with apc.stat = 0 + ----------------------------------------------------------------------- + + When using APC to cache, apc.stat is 0 and PHP caching of templates is enabled + the result won't show until cache is cleared. To get around this one can extend + Twig_Environment and force update cache when Twig rewrites the cache:: + + /** + * Modified Twig Environment for APC bytecode cache support + */ + class Twig_Environment_APC extends Twig_Environment + { + + protected function writeCacheFile($file, $content) { + parent::writeCacheFile($file, $content); + + // Compile cached file into bytecode cache + apc_compile_file($file); + } } .. _callback: http://www.php.net/manual/en/function.is-callable.php