diff options
author | Christian Schneider | 2008-12-17 15:32:46 +0000 |
---|---|---|
committer | Christian Schneider | 2008-12-17 15:32:46 +0000 |
commit | c5d6f31055323690fa1b6e29c362cd66fd765640 (patch) | |
tree | 6c5a92b22d280b8eef31ec82aeddf503e0e28551 | |
parent | e1f864f71db0907b966470726f9c3887aabfa44e (diff) | |
download | itools-c5d6f31055323690fa1b6e29c362cd66fd765640.tar.gz itools-c5d6f31055323690fa1b6e29c362cd66fd765640.tar.bz2 itools-c5d6f31055323690fa1b6e29c362cd66fd765640.zip |
Purge cache shared by multiple apaches on SQL schema change
-rw-r--r-- | it_dbi.class | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/it_dbi.class b/it_dbi.class index df79f0e..4e033b4 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -438,6 +438,12 @@ function query($query, $p = array()) if (!$result) $this->_fatal("query(\"$query\") failed"); } + else if (preg_match('/^(CREATE|ALTER|DROP) /i', $query)) + { + # Purge cache for schema changes (after modifying table) + $dbid = "{$p['user']}@{$p['server']}:{$p['db']}"; + it_dbi::_state_purgeshared($dbid); + } if ($GLOBALS['debug_sqllog']) @@ -728,6 +734,12 @@ function _state_put($dbid, $state) it_cache::put("dbi:$dbid", array('link' => null) + (array)$state); # link is not transferable } +function _state_purgeshared($dbid) +{ + #var_dump("purgeshared", $dbid); + it_cache::put("dbi:$dbid", array()); # Nuke shared cache +} + # # Implement PHP 5 Iterator interface to make foreach work # Example: foreach (new T_User('firstname' => "foo") as $foouser) { ... } |