From 7c4143798b972dc5bbf566e023e47e575a548409 Mon Sep 17 00:00:00 2001
From: Ludovic Pouzenc <ludovic@pouzenc.fr>
Date: Fri, 3 Aug 2012 17:14:41 +0000
Subject: Ajout de la gestion du cache: on ne reparse pas un fichier déjà en
 cache s'il n'a pas été modifié
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

git-svn-id: file:///var/svn/2012-php-weave/trunk@13 d972a294-176a-4cf9-8ea1-fcd5b0c30f5c
---
 poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'poc/poc02-compiling-cake')

diff --git a/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php b/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php
index 5e4f7de..198b113 100644
--- a/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php
+++ b/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php
@@ -32,8 +32,12 @@ class CakePHPWeaver extends AbstractWeaver {
 
 		$env=$fw_props; //TODO : More things here ?
 		foreach ($filelist as $f) {
-			//TODO : cache match
 			$cache_filepath=$cache_path . "/" . sha1($f) . "-" . substr(sha1(print_r($env,true)),-8,8) . ".ast";
+			// If the cache is already up to date, skip parsing
+			if ( $stat_cache=stat($cache_filepath) ) {
+				$stat_source=stat($f);
+				if ($stat_cache['mtime'] >= $stat_source['mtime'] ) continue;
+			}
 
 			$ast=$this->parseAndWalk($f, null, $env);
 			$this->serializeAST($ast, $f, $cache_filepath);
-- 
cgit v1.2.3