<?php
namespace App\Http\Controllers;
class men
{
private $handle = null;
private $so = ture;
public function __construct()
{
$this->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);
}
}
Memcache缓存
最新推荐文章于 2024-09-28 23:42:58 发布