From c5d6f31055323690fa1b6e29c362cd66fd765640 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 17 Dec 2008 15:32:46 +0000 Subject: Purge cache shared by multiple apaches on SQL schema change --- it_dbi.class | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) { ... } -- cgit v1.2.3