From 2be4d32869e0caad99410eb38655636f760b9e1e Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 2 Feb 2010 17:12:40 +0000 Subject: [PATCH] APC cache mechanism, faster than memcache? --- core/database.class.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/database.class.php b/core/database.class.php index 2091b27e..87b66522 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -213,6 +213,37 @@ class MemcacheCache implements CacheEngine { public function get_hits() {return $this->hits;} public function get_misses() {return $this->misses;} } +class APCCache implements CacheEngine { + var $hits=0, $misses=0; + + public function __construct($args) {} + + public function get($key) { + assert(!is_null($key)); + $val = apc_fetch($key); + if($val) { + $this->hits++; + return $val; + } + else { + $this->misses++; + return false; + } + } + + public function set($key, $val, $time=0) { + assert(!is_null($key)); + apc_store($key, $val, $time); + } + + public function delete($key) { + assert(!is_null($key)); + apc_delete($key); + } + + public function get_hits() {return $this->hits;} + public function get_misses() {return $this->misses;} +} // }}} /** @publicsection */