Memcache缓存

so=extension_loaded('Memcache');
        if($this->so){
            $this->handle = new Memcache();
        }
        else{
            $this->handle = new Memcached();
        }
        $this->handle-addSever('127.0.0.1',11211);


    }
    public function get(string $key){
        return $this->handle-get($key);
    }
    public function set(string $key,$value,int $time){
        if($this->so){
            return $this->so-set($key,$value,MEMCACHE_COMPRESSED,$time);
        }
        else{
            return $this->handle->set($key,$value,$time);
        }

    }
    public function del($key){
        return $this->handle->delete($key);
    }


}

你可能感兴趣的:(缓存)