serviceName; } public function setName($name) { $this->serviceName = $name; } public function init() { if ( MEMCACHED_ENABLED ){ if ( ! class_exists("Memcache") ) return false; $this->memcache = new Memcache; $this->dir = dirname(__FILE__)."/../mcache"; return $this->memcache->connect('127.0.0.1', 11211); } else { $this->memcache = new MemcacheSkeleton; return true; } } public function add($key, $var, $flag=false, $expire=false){ if ( ! $expire && $this->filecache ) $this->addF($key, $var); return $this->memcache->add($key, $var, $flag, $expire); } public function get($key) { //$this->flush(); $value = $this->memcache->get($key); if ( ($value===false) && $this->filecache ) $value = $this->getF($key); return $value; } public function set($key, $var, $flag=false, $expire=false){ //echo $key."
"; if ( ! $expire && $this->filecache ) $this->addF($key, $var, $flag=false, $expire=false); return $this->memcache->set($key, $var, $flag=false, $expire=false); } public function delete($key, $timeout=false) { if ( $this->filecache ) $this->deleteF($key); return $this->memcache->delete($key, $timeout); } public function flush(){ if ( $this->filecache ) $this->flushF(); return $this->memcache->flush(); } private function addF($key, $var){ $km = str_split(md5($key),$this->filesplitunit); $filename = end($km); unset($km[count($km)-1]); $dir_str = dirname(__FILE__)."/../mcache"; foreach ( $km as $kmo ) { $dir_str .= "/".$kmo; if ( ! is_dir($dir_str) ) mkdir($dir_str); } file_put_contents($dir_str."/".$filename, $var); } private function getF($key) { $filename = $this->getFilename($key); return is_file($filename) ? file_get_contents($filename) : false; } private function deleteF($key){ $filename = $this->getFilename($key); if ( is_file($filename) ) unlink($filename); } private function flushF(){ exec("rm -rf ".dirname(__FILE__)."/../mcache/*"); } private function getFilename($key) { return dirname(__FILE__)."/../mcache/".implode("/",str_split(md5($key),$this->filesplitunit)); } } //ha ki van kapcsolva a memcache, ez húzódik be class MemcacheSkeleton { public function add($key, $var, $flag=false, $expire=false){ return false; } public function set($key, $var, $flag=false, $expire=false){ return false; } public function get($key) { return false; } public function delete($key, $timeout=false) { return false; } public function flush(){ return false; } } ?>
Fatal error: Class 'MCache' not found in /data/_system/classes/ndengine.php on line 26