Merging fixes and enhancements into trunk.

Revision: [2270]
Refactored clearCache()

Revision: [2269]
Removed timestamp in file name.
Removed debug code in model_php5.php


git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2271 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-03-12 09:31:36 +00:00
parent 54df7c300f
commit 2862d11796
5 changed files with 44 additions and 36 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
1.0.0.2268
1.0.0.2271

View file

@ -916,7 +916,8 @@ function clearCache($params = null, $type = 'views', $ext = '.php')
$cache = CACHE.$type.DS.$params;
if(is_file($cache.$ext))
{
return unlink($cache);
@unlink($cache.$ext);
return true;
}
else if(is_dir($cache))
{
@ -925,7 +926,14 @@ function clearCache($params = null, $type = 'views', $ext = '.php')
{
return false;
}
array_map('unlink', $files);
foreach($files as $file)
{
if(is_file($file))
{
@unlink($file);
}
}
return true;
}
else
@ -936,7 +944,13 @@ function clearCache($params = null, $type = 'views', $ext = '.php')
{
return false;
}
array_map('unlink', $files);
foreach($files as $file)
{
if(is_file($file))
{
@unlink($file);
}
}
return true;
}
}
@ -953,7 +967,13 @@ function clearCache($params = null, $type = 'views', $ext = '.php')
{
if(is_array($delete))
{
array_map('unlink', $delete);
foreach($delete as $file)
{
if(is_file($file))
{
@unlink($file);
}
}
}
}
return true;

View file

@ -114,37 +114,28 @@ if(defined('CACHE_CHECK') && CACHE_CHECK === true)
$uri = setUri();
}
$pattern = str_replace('/', '_', $uri);
$filename = CACHE.'views'.DS.'*'.$pattern .'*';
$files = glob($filename);
$filename = CACHE.'views'.DS.str_replace('/', '_', $uri.'.php');
foreach ($files as $file)
if (file_exists($filename))
{
if (preg_match('/('.$pattern.')(_{0,2}\\d+)/', $file))
ob_start();
include($filename);
if (DEBUG)
{
if (file_exists($file))
echo "<!-- Cached Render Time: ". round(getMicrotime() - $TIME_START, 4) ."s -->";
}
$out = ob_get_clean();
if (preg_match('/^<!--cachetime:(\\d+)-->/', $out, $match))
{
if(time() >= $match['1'])
{
if (preg_match('/(\\d+).php/', $file, $match))
{
if(time() >= $match['1'])
{
@unlink($file);
unset($out);
}
else
{
ob_start();
include($file);
if (DEBUG)
{
echo "<!-- Cached Render Time: ". round(getMicrotime() - $TIME_START, 4) ."s -->";
}
$out = ob_get_clean();
die(e($out));
}
}
@unlink($filename);
unset($out);
}
else
{
die(e($out));
}
break;
}
}
}

View file

@ -1700,10 +1700,6 @@ class Model extends Object
}
}
}
echo "<pre>";
print_r($assoc);
echo "</pre>";
die();
clearCache($assoc);
return true;
}

View file

@ -809,8 +809,9 @@ class View extends Object
$cacheTime = $now + strtotime($timestamp);
}
$result = preg_replace('/\/\//', '/', $this->here);
$cache = str_replace('/', '_', $result.'_'.$cacheTime.'.php');
$cache = str_replace('/', '_', $result.'.php');
$cache = str_replace('favicon.ico', '', $cache);
$view = '<!--cachetime:'.$cacheTime.'-->'.$view;
return cache('views'.DS.$cache, $view, $timestamp);
}
}