From: hickert Date: Mon, 3 Sep 2007 12:27:05 +0000 (+0000) Subject: Added memcache class. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=acc5c54b634c4234f3f08ae78f2a2c149144b37f;p=gosa.git Added memcache class. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7198 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_cache_handler.inc b/include/class_cache_handler.inc new file mode 100644 index 000000000..036733333 --- /dev/null +++ b/include/class_cache_handler.inc @@ -0,0 +1,70 @@ +connect(); + } + + + function connect() + { + $this->close(); + if(class_exists("Memcache")){ + $this->c_memcache = new Memcache; + $res = $this->c_memcache->connect("localhost",11211); + if(!$res){ + $this->b_connected = FALSE; + $this->c_memcache = NULL; + }else{ + $this->b_connected = TRUE; + } + } + } + + function close() + { + if($this->b_connected){ + $this->c_memcache->close(); + } + } + + + function save($key,$value) + { + if($this->b_connected){ + $this->c_memcache->set($key,$value); + } + } + + function load($key) + { + if($this->b_connected){ + return($this->c_memcache->get($key)); + } + } + + function remove($key) + { + if($this->b_connected){ + return($this->c_memcache->delete($key)); + } + } + + function get_server_status() + { + if($this->b_connected){ + return($this->c_memcache->getStats()); + }else{ + return(FALSE); + } + } +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?>