\hymie\cacheCache

缓存,适配 Psr-6 Psr-16。 默认寻找 bean 配置中名为 'cache' 的 bean 如未配置,则使用 \hymie\cache\ArrayCache (Psr-16)

如果存在 ROOT . DIRECTORY_SEPARATOR . '.clean_cache' 文件,则会在启动时清除所有缓存,清除后 会删除该文件。

Summary

Methods
Properties
Constants
getInstance()
__construct()
checkIfNeedClean()
setCacheImpl()
getCacheImpl()
get()
set()
delete()
clear()
getMultiple()
setMultiple()
deleteMultiple()
has()
No public properties found
DEFAULT_BAEN_NAME
CLEAN_FILE
No protected methods found
No protected properties found
N/A
correctKey()
$instance
$cacheImpl
N/A

Constants

DEFAULT_BAEN_NAME

DEFAULT_BAEN_NAME

bean 定义缓存的默认 bean 名字

CLEAN_FILE

CLEAN_FILE

默认清除缓存的文件,如果系统根目录下该文件存在则清除缓存。

Properties

$instance

$instance : object

静态实例

Type

object

$cacheImpl

$cacheImpl : \Psr\SimpleCache\CacheInterface|\Psr\Cache\CacheItemPoolInterface

第三方缓存实现

Type

\Psr\SimpleCache\CacheInterface|\Psr\Cache\CacheItemPoolInterface

Methods

getInstance()

getInstance() : void

单例方法

__construct()

__construct() 

读取 bean 配置获取缓存,若未配置,则使用默认的 ArrayCache.

checkIfNeedClean()

checkIfNeedClean() : void

检查 ROOT . .clean_cache 文件是否存在,如果存在则清除缓存

setCacheImpl()

setCacheImpl(\Psr\SimpleCache\CacheInterface|\Psr\Cache\CacheItemPoolInterface  $cacheImpl) : void

设置缓存实现,若 Psr-6缓存,则使用 Psr6Adapter 进行适配,以符合 Psr-16 标准

Parameters

\Psr\SimpleCache\CacheInterface|\Psr\Cache\CacheItemPoolInterface $cacheImpl

getCacheImpl()

getCacheImpl() : \Psr\SimpleCache\CacheInterface

getter

Returns

\Psr\SimpleCache\CacheInterface

get()

get(  $key,   $default = null) 

{@inheritdoc}

Parameters

$key
$default

set()

set(  $key,   $value,   $ttl = null) 

{@inheritdoc}

Parameters

$key
$value
$ttl

delete()

delete(  $key) 

{@inheritdoc}

Parameters

$key

clear()

clear() 

{@inheritdoc}

getMultiple()

getMultiple(  $keys,   $default = null) 

{@inheritdoc}

Parameters

$keys
$default

setMultiple()

setMultiple(  $values,   $ttl = null) 

{@inheritdoc}

Parameters

$values
$ttl

deleteMultiple()

deleteMultiple(  $keys) 

{@inheritdoc}

Parameters

$keys

has()

has(  $key) 

{@inheritdoc}

Parameters

$key

correctKey()

correctKey(string  $key) : boolean

Symony 缓存实现对键名有要求,不能包含 [ ] { } ( ) \ @ : 这些字符

Parameters

string $key

Returns

boolean