PHP Class think\Cache

Show file Open project: top-think/framework Class Usage Examples

Public Properties

Property Type Description
$readTimes
$writeTimes

Protected Properties

Property Type Description
$handler object 操作句柄
$instance

Public Methods

Method Description
clear ( string $tag = null ) : boolean 清除缓存
connect ( array $options = [], boolean | string $name = false ) : Driver 连接缓存
dec ( string $name, integer $step = 1 ) : false | integer 自减缓存(针对数值缓存)
get ( string $name, mixed $default = false ) : mixed 读取缓存
has ( string $name ) : boolean 判断缓存是否存在
inc ( string $name, integer $step = 1 ) : false | integer 自增缓存(针对数值缓存)
init ( array $options = [] ) : void 自动初始化缓存
rm ( string $name ) : boolean 删除缓存
set ( string $name, mixed $value, integer | null $expire = null ) : boolean 写入缓存
store ( string $name ) : Driver 切换缓存类型 需要配置 cache.type 为 complex
tag ( string $name, string | array $keys = null, boolean $overlay = false ) : Driver 缓存标签

Method Details

clear() public static method

清除缓存
public static clear ( string $tag = null ) : boolean
$tag string 标签名
return boolean

connect() public static method

连接缓存
public static connect ( array $options = [], boolean | string $name = false ) : Driver
$options array 配置数组
$name boolean | string 缓存连接标识 true 强制重新连接
return think\cache\Driver

dec() public static method

自减缓存(针对数值缓存)
public static dec ( string $name, integer $step = 1 ) : false | integer
$name string 缓存变量名
$step integer 步长
return false | integer

get() public static method

读取缓存
public static get ( string $name, mixed $default = false ) : mixed
$name string 缓存标识
$default mixed 默认值
return mixed

has() public static method

判断缓存是否存在
public static has ( string $name ) : boolean
$name string 缓存变量名
return boolean

inc() public static method

自增缓存(针对数值缓存)
public static inc ( string $name, integer $step = 1 ) : false | integer
$name string 缓存变量名
$step integer 步长
return false | integer

init() public static method

自动初始化缓存
public static init ( array $options = [] ) : void
$options array 配置数组
return void

rm() public static method

删除缓存
public static rm ( string $name ) : boolean
$name string 缓存标识
return boolean

set() public static method

写入缓存
public static set ( string $name, mixed $value, integer | null $expire = null ) : boolean
$name string 缓存标识
$value mixed 存储数据
$expire integer | null 有效时间 0为永久
return boolean

store() public static method

切换缓存类型 需要配置 cache.type 为 complex
public static store ( string $name ) : Driver
$name string 缓存标识
return think\cache\Driver

tag() public static method

缓存标签
public static tag ( string $name, string | array $keys = null, boolean $overlay = false ) : Driver
$name string 标签名
$keys string | array 缓存标识
$overlay boolean 是否覆盖
return think\cache\Driver

Property Details

$handler protected static property

操作句柄
protected static object $handler
return object

$instance protected static property

protected static $instance

$readTimes public static property

public static $readTimes

$writeTimes public static property

public static $writeTimes