Memcached形式缓存类

仅适用于linux,需要Memcached扩展
属性
命名空间 fize\cache\handler
类名 Memcached
实现接口 fize\cache\CacheHandler
方法:
方法名 说明
__construct() 构造函数
__destruct() 析构函数
get() 获取一个缓存
has() 查看指定缓存是否存在
set() 设置一个缓存
remove() 删除一个缓存
clear() 清空缓存

方法

__construct()

构造函数

public function __construct (

    array $config = []

)
参数:
名称 说明
config 初始化默认选项

__destruct()

析构函数

public function __destruct ()

get()

获取一个缓存

public function get (

    string $name,

    mixed $default = null

) : mixed
参数:
名称 说明
name 缓存名
default 默认值

has()

查看指定缓存是否存在

public function has (

    string $name

) : bool
参数:
名称 说明
name 缓存名

set()

设置一个缓存

public function set (

    string $name,

    mixed $value,

    int $expire = null

)
参数:
名称 说明
name 缓存名
value 缓存值
expire 有效时间,以秒为单位,0表示永久有效。
参数 `$expire` :
不设置则使用当前配置

remove()

删除一个缓存

public function remove (

    string $name

)
参数:
名称 说明
name 缓存名

clear()

清空缓存

public function clear ()