aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/acm
diff options
context:
space:
mode:
authorLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2003-08-12 15:46:03 +0000
committerLudovic Arnaud <ludovic_arnaud@users.sourceforge.net>2003-08-12 15:46:03 +0000
commit567ff01df1d1b592f7c24afd68a08cafe1cd3712 (patch)
tree07ba0538cabc5636a36cf23b2ef745147b03b200 /phpBB/includes/acm
parentf584f14af94552992a7a558d50e376fcd1782c8a (diff)
downloadforums-567ff01df1d1b592f7c24afd68a08cafe1cd3712.tar
forums-567ff01df1d1b592f7c24afd68a08cafe1cd3712.tar.gz
forums-567ff01df1d1b592f7c24afd68a08cafe1cd3712.tar.bz2
forums-567ff01df1d1b592f7c24afd68a08cafe1cd3712.tar.xz
forums-567ff01df1d1b592f7c24afd68a08cafe1cd3712.zip
Added: ability to destroy specific SQL caches
git-svn-id: file:///svn/phpbb/trunk@4389 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/acm')
-rw-r--r--phpBB/includes/acm/acm_db.php2
-rw-r--r--phpBB/includes/acm/acm_file.php37
2 files changed, 31 insertions, 8 deletions
diff --git a/phpBB/includes/acm/acm_db.php b/phpBB/includes/acm/acm_db.php
index a9e1866616..ca17abe63a 100644
--- a/phpBB/includes/acm/acm_db.php
+++ b/phpBB/includes/acm/acm_db.php
@@ -136,7 +136,7 @@ class acm
$this->is_modified = TRUE;
}
- function destroy($var_name)
+ function destroy($var_name, $void = NULL)
{
if (isset($this->vars[$var_name]))
{
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php
index 30548f5a5a..1248955e01 100644
--- a/phpBB/includes/acm/acm_file.php
+++ b/phpBB/includes/acm/acm_file.php
@@ -73,12 +73,12 @@ class acm
$dir = opendir($this->cache_dir);
while ($entry = readdir($dir))
{
- if ($entry{0} == '.' || substr($entry, 0, 4) != 'sql_')
+ if (substr($entry, 0, 4) != 'sql_')
{
continue;
}
- if (filemtime($this->cache_dir . $entry) + $max_age < time() )
+ if (time() > filemtime($this->cache_dir . $entry) + $max_age)
{
unlink($this->cache_dir . $entry);
}
@@ -88,7 +88,7 @@ class acm
{
foreach ($this->vars_ts as $var_name => $timestamp)
{
- if ($timestamp + $max_age < time())
+ if (time() > $timestamp + $max_age)
{
$this->destroy($var_name);
}
@@ -113,9 +113,32 @@ class acm
$this->is_modified = TRUE;
}
- function destroy($var_name)
+ function destroy($var_name, $table = '')
{
- if (isset($this->vars[$var_name]))
+ if ($var_name == 'sql' && !empty($table))
+ {
+ $regex = '(' . ((is_array($table)) ? implode('|', $table) : $table) . ')';
+
+ $dir = opendir($this->cache_dir);
+ while ($entry = readdir($dir))
+ {
+ if (substr($entry, 0, 4) != 'sql_')
+ {
+ continue;
+ }
+
+ $fp = fopen($this->cache_dir . $entry, 'rb');
+ $file = fread($fp, filesize($this->cache_dir . $entry));
+ @fclose($fp);
+
+ if (preg_match('#/\*.*?\W' . $regex . '\W.*?\*/#s', $file, $m))
+ {
+ unlink($this->cache_dir . $entry);
+ }
+ @closedir($dir);
+ }
+ }
+ elseif (isset($this->vars[$var_name]))
{
$this->is_modified = TRUE;
unset($this->vars[$var_name]);
@@ -132,7 +155,7 @@ class acm
if ($max_age > 0 && isset($this->vars_ts[$var_name]))
{
- if ($this->vars_ts[$var_name] + $max_age < time())
+ if (time() > $this->vars_ts[$var_name] + $max_age)
{
$this->destroy($var_name);
return FALSE;
@@ -175,7 +198,7 @@ class acm
$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);
$filemtime = intval(@filemtime($this->cache_dir . 'sql_' . md5($query) . '.' . $phpEx));
- if ($filemtime + $max_age < time())
+ if (time() > $filemtime + $max_age)
{
return FALSE;
}