\Imi\Cache\AnnotationCacheable

缓存注解

调用方法前检测是否存在缓存,如果存在直接返回;不存在则执行方法体,然后将返回值存入缓存

Summary

Methods
Properties
Constants
__construct()
offsetGet()
__wakeup()
offsetExists()
offsetSet()
offsetUnset()
current()
key()
next()
rewind()
valid()
__set()
__get()
__isset()
__unset()
toArray()
jsonSerialize()
$name
$key
$ttl
$lockable
$preventBreakdown
$hashMethod
No constants found
No protected methods found
$defaultFieldName
N/A
No private methods found
$data
N/A

Properties

$name

$name : string|null

缓存器名称 为null则使用默认缓存器

Type

string|null

$key

$key : string

缓存键名 支持{id}、{data.name}形式,代入参数 支持{:args}代入所有方法参数的 hash 值 如果为null,则使用类名+方法名+全部参数,序列化后hash

Type

string

$ttl

$ttl : integer

缓存超时时间,单位:秒

Type

integer

$preventBreakdown

$preventBreakdown : boolean

防止缓存击穿 如果设为 true,会在获得锁后,尝试获取缓存,如果缓存存在则不再执行方法体

需要配合 $lockable 属性使用

Type

boolean

$hashMethod

$hashMethod : string

可以指定 hash 方法,默认为:md5

Type

string

$defaultFieldName

$defaultFieldName : string

只传一个参数时的参数名

Type

string

$data

$data : array

数据

Type

array

Methods

__construct()

__construct(  $data = array()) 

Parameters

$data

offsetGet()

offsetGet(  $offset) 

Parameters

$offset

__wakeup()

__wakeup() 

offsetExists()

offsetExists(  $offset) 

Parameters

$offset

offsetSet()

offsetSet(  $offset,   $value) 

Parameters

$offset
$value

offsetUnset()

offsetUnset(  $offset) 

Parameters

$offset

current()

current() 

key()

key() 

next()

next() 

rewind()

rewind() 

valid()

valid() 

__set()

__set(  $name,   $value) 

Parameters

$name
$value

__get()

__get(  $name) 

Parameters

$name

__isset()

__isset(  $name) 

Parameters

$name

__unset()

__unset(  $name) 

Parameters

$name

toArray()

toArray() : array

将当前对象作为数组返回

Returns

array

jsonSerialize()

jsonSerialize() : array

json 序列化

Returns

array