PHP 트레잇 luya\traits\CacheableTrait

Concret implementation example: $cacheKey = 'foobar'; $cache = $this->getHasCache($cacheKey); if ($cache === false) { execute code and save cache data into variable $this->setHasCache($cacheKey, $cache); // variable $cache has been changed from above } return $cache;
부터: 1.0.0-beta4
저자: nadar
파일 보기 프로젝트 열기: luyadev/luya

공개 프로퍼티들

프로퍼티 타입 설명
$cacheEnabled If enabled and the cache component is available. If disabled it will fully ignore the any caching but does not throw exception.
$cacheExpiration Defined the duration of the caching lifetime in seconds. 3600 = 1 hour, 86400 = 24 hours. 0 is forever

공개 메소드들

메소드 설명
deleteHasCache ( string | array $key ) : boolean Remove a value from the cache if caching is enabled.
getHasCache ( string | array $key ) : mixed | boolean Get the caching data if caching is allowed and there is any data stored for this key.
isCachable ( ) : boolean Check if the current configuration of the application and the property allows a caching of the language container data.
setHasCache ( string | array $key, mixed $value, yii\caching\Dependency | array $dependency = null, $cacheExpiration = null ) : boolean Store cache data for a specific key if caching is enabled in this application.

메소드 상세

deleteHasCache() 공개 메소드

Remove a value from the cache if caching is enabled.
public deleteHasCache ( string | array $key ) : boolean
$key string | array The cache identifier
리턴 boolean Whether delete of key has been success or not

getHasCache() 공개 메소드

Get the caching data if caching is allowed and there is any data stored for this key.
public getHasCache ( string | array $key ) : mixed | boolean
$key string | array The identifiere key, can be a string or an array which will be calculated.
리턴 mixed | boolean Returns the data, if not found returns false.

isCachable() 공개 메소드

Check if the current configuration of the application and the property allows a caching of the language container data.
public isCachable ( ) : boolean
리턴 boolean

setHasCache() 공개 메소드

Store cache data for a specific key if caching is enabled in this application.
public setHasCache ( string | array $key, mixed $value, yii\caching\Dependency | array $dependency = null, $cacheExpiration = null ) : boolean
$key string | array The identifier key or a array to store complex keys
$value mixed The value to store in the cache component.
$dependency yii\caching\Dependency | array Dependency of the cached item. If the dependency changes, the corresponding value in the cache will be invalidated when it is fetched via get(). This parameter is ignored if $serializer is false. You can also define an array with defintion which will generate the Object instead of object is provided.
리턴 boolean Whether set has been success or not

프로퍼티 상세

$cacheEnabled 공개적으로 프로퍼티

If enabled and the cache component is available. If disabled it will fully ignore the any caching but does not throw exception.
public $cacheEnabled

$cacheExpiration 공개적으로 프로퍼티

Defined the duration of the caching lifetime in seconds. 3600 = 1 hour, 86400 = 24 hours. 0 is forever
public $cacheExpiration