菜单

Clear cache in typo3

2015年01月11日 - typo3

TYPO3 6.x

first initialize the Service in your Class

/**
 * @var \TYPO3\CMS\Extbase\Service\CacheService
 */
protected $cacheService;

/**
 * @param \TYPO3\CMS\Extbase\Service\CacheService $cacheService
 * @return void
 */
public function injectCacheService(\TYPO3\CMS\Extbase\Service\CacheService $cacheService) {
    $this->cacheService = $cacheService;
}

in your function just call

$this->cacheService->clearPageCache($pids);

while $pids is an integer (for single page) or array of integers (multiple pages)

see: http://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_extbase_1_1_service_1_1_cache_service.html

In TYPO3 since 4.5 (I think) its a static method so you have just to call

Tx_Extbase_Utility_Cache::clearPageCache($pids);

in your controller.

Found it here: http://www.phpkode.com/source/p/typo-cms/typo3_src+dummy-4.6.5/typo3/sysext/extbase/Classes/MVC/Controller/ActionController.php

发表评论

电子邮件地址不会被公开。 必填项已用*标注