diff --git a/config.ini.php b/config.ini.php index d0f9ca7..842cb98 100644 --- a/config.ini.php +++ b/config.ini.php @@ -8,14 +8,14 @@ DEBUG_MODE = ON [SERVER] -SERVER = 127.0.0.1 +SERVER = localhost PORT = 11211 [AUTH] PASSWORD = 81b637d8fcd2c6da6359e6963113a1170de795e4b725b84d1e0b4cfd9ec58ce9 [MISC] -PHP_TIMEZONE = Europe/London +PHP_TIMEZONE = UTC diff --git a/delete.php b/delete.php index 3ccec78..46a9c2f 100644 --- a/delete.php +++ b/delete.php @@ -11,19 +11,9 @@ $config = parse_ini_file('config.ini.php', true); - /* - * Because of an API change on Memcache's side, the PHP module's 'delete' - * doesn't work (it hasn't been updated). I've used raw sockets instead. - * - * See http://pecl.php.net/bugs/bug.php?id=16927 for bug report. - */ - - $fs = fsockopen($config['SERVER']['SERVER'], $config['SERVER']['PORT']); - - fwrite($fs, 'delete ' . $_GET['delete_item'] . "\r\n"); - - fclose($fs); - + $MEMCACHE = new Memcache(); + $MEMCACHE->connect($config['SERVER']['SERVER'], $config['SERVER']['PORT']); + $MEMCACHE->delete($_GET['delete_item']); } header("Location: index.php"); diff --git a/scripts/reload.js b/scripts/reload.js index 73f45bf..e7a82cc 100644 --- a/scripts/reload.js +++ b/scripts/reload.js @@ -13,10 +13,14 @@ function setRefreshInterval(){ interval = setInterval('pageReload()', 1000 * document.getElementById('refresh_rate').value); } -function pageReload(){ +function pageReload(flush){ $("img#loading_gif").removeClass("hidden"); - $("div#content").load("viewer.php", colourExpired); + if (flush) + $("div#content").load("viewer.php?flush=1", colourExpired); + else + $("div#content").load("viewer.php", colourExpired); + setTimeout(function(){$("img#loading_gif").addClass("hidden")}, 100); } diff --git a/template/header.html b/template/header.html index 58235aa..8dcfd5d 100644 --- a/template/header.html +++ b/template/header.html @@ -19,6 +19,7 @@

MemcacheViewer

+ Flush entries
diff --git a/viewer.php b/viewer.php index fb041b3..bcedc8d 100644 --- a/viewer.php +++ b/viewer.php @@ -29,7 +29,7 @@ or die('Memcache PHP module doesn\'t appear to be installed. It is needed.'); $MEMCACHE = new Memcache(); -$MEMCACHE->pconnect(SERVER, PORT); +$MEMCACHE->connect(SERVER, PORT); //set timezone date_default_timezone_set(isset($config['MISC']['PHP_TIMEZONE']) @@ -60,6 +60,12 @@ } +if (isset($_GET['flush']) && $_GET['flush'] == 1) { + // $MEMCACHE->flush() does not work in the windows memcached-driver implementation I found ... + foreach(array_keys($items) as $item_key) { + $MEMCACHE->delete($item_key); + } +} /* * Time to display some output.