Properties

$handler

$handler : object

驱动句柄

Type

object

$readTimes

$readTimes : int

缓存读取次数

Type

int

$writeTimes

$writeTimes : int

缓存写入次数

Type

int

$options

$options : array

配置参数

Type

array

$tag

$tag : array

缓存标签

Type

array

Methods

getCacheKey()

getCacheKey(string  $name) : string

取得变量的存储文件名

Parameters

string $name

缓存变量名

Returns

string —

pull()

pull(string  $name) : mixed

读取缓存并删除

Parameters

string $name

缓存变量名

Returns

mixed —

push()

push(string  $name, mixed  $value) : void

追加(数组)缓存

Parameters

string $name

缓存变量名

mixed $value

存储数据

remember()

remember(string  $name, mixed  $value, int  $expire = null) : mixed

如果不存在则写入缓存

Parameters

string $name

缓存变量名

mixed $value

存储数据

int $expire

有效时间 0为永久

Returns

mixed —

tag()

tag(string|array  $name) : \think\cache\TagSet

缓存标签

Parameters

string|array $name

标签名

Returns

\think\cache\TagSet —

getTagItems()

getTagItems(string  $tag) : array

获取标签包含的缓存标识

Parameters

string $tag

标签标识

Returns

array —

getTagKey()

getTagKey(string  $tag) : string

获取实际标签名

Parameters

string $tag

标签名

Returns

string —

handler()

handler() : object

返回句柄对象,可执行其它高级方法

Returns

object —

getReadTimes()

getReadTimes() : int

返回缓存读取次数

Returns

int —

getWriteTimes()

getWriteTimes() : int

返回缓存写入次数

Returns

int —

getMultiple()

getMultiple(iterable  $keys, mixed  $default = null) : iterable

读取缓存

Parameters

iterable $keys

缓存变量名

mixed $default

默认值

Throws

\think\exception\InvalidArgumentException

Returns

iterable —

setMultiple()

setMultiple(iterable  $values, null|int|\DateInterval  $ttl = null) : bool

写入缓存

Parameters

iterable $values

缓存数据

null|int|\DateInterval $ttl

有效时间 0为永久

Returns

bool —

deleteMultiple()

deleteMultiple(iterable  $keys) : bool

删除缓存

Parameters

iterable $keys

缓存变量名

Throws

\think\exception\InvalidArgumentException

Returns

bool —

__call()

__call(mixed  $method, mixed  $args) : mixed

Parameters

mixed $method
mixed $args

Returns

mixed —

__construct()

__construct(\think\App  $app, array  $options = []) : mixed

架构函数

Parameters

\think\App $app
array $options

参数

Returns

mixed —

has()

has(string  $name) : bool

判断缓存是否存在

Parameters

string $name

缓存变量名

Returns

bool —

get()

get(string  $name, mixed  $default = null) : mixed

读取缓存

Parameters

string $name

缓存变量名

mixed $default

默认值

Returns

mixed —

set()

set(string  $name, mixed  $value, int|\DateTime  $expire = null) : bool

写入缓存

Parameters

string $name

缓存变量名

mixed $value

存储数据

int|\DateTime $expire

有效时间 0为永久

Returns

bool —

inc()

inc(string  $name, int  $step = 1) : false|int

自增缓存(针对数值缓存)

Parameters

string $name

缓存变量名

int $step

步长

Returns

false|int —

dec()

dec(string  $name, int  $step = 1) : false|int

自减缓存(针对数值缓存)

Parameters

string $name

缓存变量名

int $step

步长

Returns

false|int —

delete()

delete(string  $name) : bool

删除缓存

Parameters

string $name

缓存变量名

Returns

bool —

clear()

clear() : bool

清除缓存

Returns

bool —

clearTag()

clearTag(array  $keys) : void

删除缓存标签

Parameters

array $keys

缓存标识列表

getExpireTime()

getExpireTime(int|\DateTimeInterface|\DateInterval  $expire) : int

获取有效期

Parameters

int|\DateTimeInterface|\DateInterval $expire

有效期

Returns

int —

serialize()

serialize(mixed  $data) : string

序列化数据

Parameters

mixed $data

缓存数据

Returns

string —

unserialize()

unserialize(string  $data) : mixed

反序列化数据

Parameters

string $data

缓存数据

Returns

mixed —

getRaw()

getRaw(string  $name) : array|null

获取缓存数据

Parameters

string $name

缓存标识名

Returns

array|null —

unlink()

unlink(string  $path) : bool

判断文件是否存在后,删除

Parameters

string $path

Returns

bool —

rmdir()

rmdir( $dirname) : bool

删除文件夹

Parameters

$dirname

Returns

bool —