changed the Array and String loaders to actually make use of the cache mechanism
authorfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Mon, 14 Dec 2009 07:05:06 +0000 (07:05 +0000)
committerfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Mon, 14 Dec 2009 07:05:06 +0000 (07:05 +0000)
git-svn-id: http://svn.twig-project.org/trunk@178 93ef8e89-cb99-4229-a87c-7fa0fa45744b

CHANGELOG
doc/03-Twig-for-Developers.markdown
lib/Twig/Loader/Array.php
lib/Twig/Loader/String.php

index afa74ac..a9cd814 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,6 @@
 * 0.9.5-DEV
 
+ * changed the Array and String loaders to actually make use of the cache mechanism
  * included the default filter function definitions in the extension class files directly (Core, Escaper)
  * added the .. operator (as a syntactic sugar for the range filter when the step is 1)
  * added the in operator (as a syntactic sugar for the in filter)
index 6df907b..24fed8a 100644 (file)
@@ -150,6 +150,13 @@ Here a list of the built-in loaders Twig provides:
         [php]
         $loader = new Twig_Loader_Array($templates);
 
+>**TIP**
+>When using the `Array` or `String` loaders with a cache mechanism, you should
+>know that a new cache key is generated each time a template content "changes"
+>(the cache key being the source code of the template). If you don't want to
+>see your cache grows out of control, you need to take care of clearing the old
+>cache file by yourself.
+
 ### Create your own Loader
 
 All loaders implement the `Twig_LoaderInterface`:
index 2d3fbe7..c62f935 100644 (file)
 /**
  * Loads a template from an array.
  *
+ * When using this loader with a cache mehcanism, you should know that a new cache
+ * key is generated each time a template content "changes" (the cache key being the
+ * source code of the template). If you don't want to see your cache grows out of
+ * control, you need to take care of clearing the old cache file by yourself.
+ *
  * @package    twig
  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  * @version    SVN: $Id$
@@ -78,6 +83,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface
    */
   public function isFresh($name, $time)
   {
-    return false;
+    return true;
   }
 }
index 1c3eb1b..5fe451d 100644 (file)
 /**
  * Loads a template from a string.
  *
+ * When using this loader with a cache mechanism, you should know that a new cache
+ * key is generated each time a template content "changes" (the cache key being the
+ * source code of the template). If you don't want to see your cache grows out of
+ * control, you need to take care of clearing the old cache file by yourself.
+ *
  * @package    twig
  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  * @version    SVN: $Id$
@@ -50,6 +55,6 @@ class Twig_Loader_String implements Twig_LoaderInterface
    */
   public function isFresh($name, $time)
   {
-    return false;
+    return true;
   }
 }