class Memcache{ private static $mem = null; public function mem_create(){ self::$mem = new Memcache(); self::$mem->connect('127.0.0.1'); } public function __destruct(){ if(self::$mem instanceof Memcache) self::$mem->close(); } public fucntion mem_set($k,$v,$boolean = false,$expire = 300){ if(!self::$mem instanceof Memcache) $this->mem_create(); return self::$mem->set($k,$v,$boolean,$e); } public fucntion mem_add($k,$v,$boolean = false,$expire = 300){ if(!self::$mem instanceof Memcache) $this->mem_create(); return self::$mem->add($k,$v,$boolean,$e); } public fucntion mem_get($k){ if(!self::$mem instanceof Memcache) $this->mem_create(); return self::$mem->get($k); } }