PHP 클래스 yii\widgets\FragmentCache

부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Widget
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$cache the cache object or the application component ID of the cache object. After the FragmentCache object is created, if you want to change this property, you should only assign it with a cache object. Starting from version 2.0.2, this can also be a configuration array for creating the object.
$dependency the dependency that the cached content depends on. This can be either a [[Dependency]] object or a configuration array for creating the dependency object. For example, php [ 'class' => 'yii\caching\DbDependency', 'sql' => 'SELECT MAX(updated_at) FROM post', ] would make the output cache depends on the last modified time of all posts. If any post has its modification time changed, the cached content would be invalidated.
$duration number of seconds that the data can remain valid in cache. Use 0 to indicate that the cached data will never expire.
$dynamicPlaceholders a list of placeholders for embedding dynamic contents. This property is used internally to implement the content caching feature. Do not modify it.
$enabled whether to enable the fragment cache. You may use this property to turn on and off the fragment cache according to specific setting (e.g. enable fragment cache only for GET requests).
$variations list of factors that would cause the variation of the content being cached. Each factor is a string representing a variation (e.g. the language, a GET parameter). The following variation setting will cause the content to be cached in different versions according to the current application language: php [ Yii::$app->language, ]

공개 메소드들

메소드 설명
getCachedContent ( ) : string | false Returns the cached content if available.
init ( ) Initializes the FragmentCache object.
run ( ) Marks the end of content to be cached.

보호된 메소드들

메소드 설명
calculateKey ( ) : mixed Generates a unique key used for storing the content in cache.
updateDynamicContent ( string $content, array $placeholders ) : string Replaces placeholders in content by results of evaluated dynamic statements.

메소드 상세

calculateKey() 보호된 메소드

The key generated depends on both [[id]] and [[variations]].
protected calculateKey ( ) : mixed
리턴 mixed a valid cache key

getCachedContent() 공개 메소드

Returns the cached content if available.
public getCachedContent ( ) : string | false
리턴 string | false the cached content. False is returned if valid content is not found in the cache.

init() 공개 메소드

Initializes the FragmentCache object.
public init ( )

run() 공개 메소드

Content displayed before this method call and after FragmentCache::init will be captured and saved in cache. This method does nothing if valid content is already found in cache.
public run ( )

updateDynamicContent() 보호된 메소드

Replaces placeholders in content by results of evaluated dynamic statements.
protected updateDynamicContent ( string $content, array $placeholders ) : string
$content string
$placeholders array
리턴 string final content

프로퍼티 상세

$cache 공개적으로 프로퍼티

the cache object or the application component ID of the cache object. After the FragmentCache object is created, if you want to change this property, you should only assign it with a cache object. Starting from version 2.0.2, this can also be a configuration array for creating the object.
public $cache

$dependency 공개적으로 프로퍼티

the dependency that the cached content depends on. This can be either a [[Dependency]] object or a configuration array for creating the dependency object. For example, php [ 'class' => 'yii\caching\DbDependency', 'sql' => 'SELECT MAX(updated_at) FROM post', ] would make the output cache depends on the last modified time of all posts. If any post has its modification time changed, the cached content would be invalidated.
public $dependency

$duration 공개적으로 프로퍼티

number of seconds that the data can remain valid in cache. Use 0 to indicate that the cached data will never expire.
public $duration

$dynamicPlaceholders 공개적으로 프로퍼티

a list of placeholders for embedding dynamic contents. This property is used internally to implement the content caching feature. Do not modify it.
public $dynamicPlaceholders

$enabled 공개적으로 프로퍼티

whether to enable the fragment cache. You may use this property to turn on and off the fragment cache according to specific setting (e.g. enable fragment cache only for GET requests).
public $enabled

$variations 공개적으로 프로퍼티

list of factors that would cause the variation of the content being cached. Each factor is a string representing a variation (e.g. the language, a GET parameter). The following variation setting will cause the content to be cached in different versions according to the current application language: php [ Yii::$app->language, ]
public $variations