2 /***************************************************************
5 * (c) 2011 Extbase Team
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
26 * Cache clearing helper functions
31 class Tx_Extbase_Service_CacheService
implements t3lib_Singleton
{
34 * Clears the page cache
36 * @param mixed $pageIdsToClear (int) single or (array) multiple pageIds to clear the cache for
39 public function clearPageCache($pageIdsToClear = NULL) {
40 if ($pageIdsToClear !== NULL && !is_array($pageIdsToClear)) {
41 $pageIdsToClear = array(intval($pageIdsToClear));
44 $this->flushPageCache($pageIdsToClear);
45 $this->flushPageSectionCache($pageIdsToClear);
49 * Flushes cache_pages or cachingframework_cache_pages.
51 * @param array $pageIdsToClear pageIds to clear the cache for
54 protected function flushPageCache($pageIds = NULL) {
55 $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
57 if ($pageIds !== NULL) {
58 foreach ($pageIds as $pageId) {
59 $pageCache->flushByTag('pageId_' . $pageId);
67 * Flushes cache_pagesection or cachingframework_cache_pagesection.
69 * @param array $pageIdsToClear pageIds to clear the cache for
72 protected function flushPageSectionCache($pageIds = NULL) {
73 $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
75 if ($pageIds !== NULL) {
76 foreach ($pageIds as $pageId) {
77 $pageSectionCache->flushByTag('pageId_' . $pageId);
80 $pageSectionCache->flush();