- improved speed of cache->clear() when a compile_id was specified and use_sub_dirs is true

This commit is contained in:
Uwe.Tews
2010-06-21 20:10:22 +00:00
parent 7626cbf093
commit f7fd63e890
2 changed files with 42 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
21/06/2010 21/06/2010
- removed use of PHP shortags SMARTY_PHP_PASSTHRU mode - removed use of PHP shortags SMARTY_PHP_PASSTHRU mode
- improved speed of cache->clear() when a compile_id was specified and use_sub_dirs is true
20/06/2010 20/06/2010
- replace internal get_time() calls with standard PHP5 microtime(true) calls - replace internal get_time() calls with standard PHP5 microtime(true) calls

View File

@@ -129,6 +129,11 @@ class Smarty_Internal_CacheResource_File {
if (isset($_cache_id)) { if (isset($_cache_id)) {
$_cache_id_parts = explode('|', $_cache_id); $_cache_id_parts = explode('|', $_cache_id);
$_cache_id_parts_count = count($_cache_id_parts); $_cache_id_parts_count = count($_cache_id_parts);
if ($this->smarty->use_sub_dirs) {
foreach ($_cache_id_parts as $id_part) {
$_dir .= $id_part . DS;
}
}
} }
if (isset($resource_name)) { if (isset($resource_name)) {
$_save_stat = $this->smarty->caching; $_save_stat = $this->smarty->caching;
@@ -144,6 +149,7 @@ class Smarty_Internal_CacheResource_File {
} }
} }
$_count = 0; $_count = 0;
if (file_exists($_dir)) {
$_cacheDirs = new RecursiveDirectoryIterator($_dir); $_cacheDirs = new RecursiveDirectoryIterator($_dir);
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_cache as $_file) { foreach ($_cache as $_file) {
@@ -185,6 +191,7 @@ class Smarty_Internal_CacheResource_File {
$_count += @unlink((string) $_file) ? 1 : 0; $_count += @unlink((string) $_file) ? 1 : 0;
} }
} }
}
return $_count; return $_count;
} }
} }