From fcca11f20c8aa3eb8ba55d727cfddf12501d7132 Mon Sep 17 00:00:00 2001
From: Shish <webmaster@shishnet.org>
Date: Tue, 20 Jan 2009 03:54:43 -0800
Subject: [PATCH] make cache engines work <_<

---
 core/database.class.php  | 17 +++++++++++++----
 core/imageboard.pack.php |  4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/core/database.class.php b/core/database.class.php
index 54839976..15bf2133 100644
--- a/core/database.class.php
+++ b/core/database.class.php
@@ -74,18 +74,24 @@ class PostgreSQL extends DBEngine {
 // }}}
 // {{{ cache engines
 interface CacheEngine {
-	var $hits = 0, $misses = 0;
-
 	public function get($key);
-	public function set($key, $val, $time);
+	public function set($key, $val, $time=0);
 	public function delete($key);
+
+	public function get_hits();
+	public function get_misses();
 }
 class NoCache implements CacheEngine {
 	public function get($key) {return false;}
-	public function set($key) {}
+	public function set($key, $val, $time=0) {}
 	public function delete($key) {}
+
+	public function get_hits() {return 0;}
+	public function get_misses() {return 0;}
 }
 class MemCache implements CacheEngine {
+	var $hits=0, $misses=0;
+
 	public function __construct($args) {
 		$this->memcache = new Memcache;
 		$this->memcache->pconnect('localhost', 11211) or ($this->use_memcache = false);
@@ -113,6 +119,9 @@ class MemCache implements CacheEngine {
 		assert(!is_null($key));
 		$this->memcache->delete($key);
 	}
+
+	public function get_hits() {return $this->hits;}
+	public function get_misses() {return $this->misses;}
 }
 // }}}
 
diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php
index 3d1f1945..13e3cd71 100644
--- a/core/imageboard.pack.php
+++ b/core/imageboard.pack.php
@@ -528,8 +528,8 @@ function get_debug_info() {
 	$i_files = count(get_included_files());
 	global $_execs;
 	global $database;
-	$hits = $database->cache->hits;
-	$miss = $database->cache->misses;
+	$hits = $database->cache->get_hits();
+	$miss = $database->cache->get_misses();
 	$debug = "<br>Took $i_utime + $i_stime seconds and {$i_mem}MB of RAM";
 	$debug .= "; Used $i_files files and $_execs queries";
 	$debug .= "; Sent $_event_count events";