\thinkCache

Summary

Methods
Properties
Constants
connect()
init()
store()
has()
get()
set()
inc()
dec()
rm()
clear()
pull()
remember()
tag()
$instance
$readTimes
$writeTimes
$handler
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$instance

$instance : array

Type

array — 缓存的实例

$readTimes

$readTimes : int

Type

int — 缓存读取次数

$writeTimes

$writeTimes : int

Type

int — 缓存写入次数

$handler

$handler : object

Type

object — 操作句柄

Methods

connect()

connect(array  $options = [], bool|string  $name = false) : \think\cache\Driver

连接缓存驱动

Parameters

array $options

配置数组

bool|string $name

缓存连接标识 true 强制重新连接

Returns

\think\cache\Driver —

init()

init(array  $options = []) : \think\cache\Driver

自动初始化缓存

Parameters

array $options

配置数组

Returns

\think\cache\Driver —

store()

store(string  $name = '') : \think\cache\Driver

切换缓存类型 需要配置 cache.type 为 complex

Parameters

string $name

缓存标识

Returns

\think\cache\Driver —

has()

has(string  $name) : bool

判断缓存是否存在

Parameters

string $name

缓存变量名

Returns

bool —

get()

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

读取缓存

Parameters

string $name

缓存标识

mixed $default

默认值

Returns

mixed —

set()

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

写入缓存

Parameters

string $name

缓存标识

mixed $value

存储数据

int|null $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 —

rm()

rm(string  $name) : bool

删除缓存

Parameters

string $name

缓存标识

Returns

bool —

clear()

clear(string  $tag = null) : bool

清除缓存

Parameters

string $tag

标签名

Returns

bool —

pull()

pull(string  $name) : mixed

读取缓存并删除

Parameters

string $name

缓存变量名

Returns

mixed —

remember()

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

如果不存在则写入缓存

Parameters

string $name

缓存变量名

mixed $value

存储数据

int $expire

有效时间 0为永久

Returns

mixed —

tag()

tag(string  $name, string|array  $keys = null, bool  $overlay = false) : \think\cache\Driver

缓存标签

Parameters

string $name

标签名

string|array $keys

缓存标识

bool $overlay

是否覆盖

Returns

\think\cache\Driver —