isMemcache =false; $obj =new \memcached(); } $obj ->addServer($host,$port); $this ->conn =$obj; } //获取数据 public function get($key) { return $this->conn->get($key); } //设置数据 public function set($key,$value,$expire=0) { if($this->isMemcache){ $this->conn->set($key,$value,$expire); }else{ // Memcached扩展的操作方式 $this->conn->set($key,$value,$expire); } } }