From 9d40eda409cc29c08b72364864b39a1191572ab4 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 1 Feb 2010 16:11:00 +0000 Subject: [PATCH] make memcaching work for pages, and log if DEBUG is set --- core/util.inc.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index e5774191..10169dc2 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -309,7 +309,7 @@ function check_cli() { function _count_execs($db, $sql, $inputarray) { global $_execs; if(DEBUG) { - $fp = @fopen("sql.log", "a"); + $fp = @fopen("data/sql.log", "a"); if($fp) { if(is_array($inputarray)) { fwrite($fp, preg_replace('/\s+/msi', ' ', $sql)." -- ".join(", ", $inputarray)."\n"); @@ -858,6 +858,14 @@ function _cache_active() { ); } +function _cache_log($text) { + $fp = @fopen("data/cache.log", "a"); + if($fp) { + fputs($fp, $text); + fclose($fp); + } +} + function _start_cache() { global $_cache_hash, $_cache_memcache, $_cache_filename; @@ -867,7 +875,11 @@ function _start_cache() { if(CACHE_MEMCACHE) { $_cache_memcache = new Memcache; $_cache_memcache->pconnect('localhost', 11211); - $zdata = $_cache_memcache->get($hash); + $zdata = $_cache_memcache->get($_cache_hash); + if(DEBUG) { + $stat = $zdata ? "hit" : "miss"; + _cache_log(time() . " " . $_cache_hash . sprintf(" %-12s ", $stat) . $_SERVER["QUERY_STRING"] . "\n"); + } if($zdata) { header("Content-type: text/html"); $data = @gzuncompress($zdata);