[CLEANUP] Remove old SVN comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Service / CacheService.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Service;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011 Extbase Team
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Cache clearing helper functions
28 */
29 class CacheService implements \TYPO3\CMS\Core\SingletonInterface {
30
31 /**
32 * Clears the page cache
33 *
34 * @param mixed $pageIdsToClear (int) single or (array) multiple pageIds to clear the cache for
35 * @return void
36 */
37 public function clearPageCache($pageIdsToClear = NULL) {
38 if ($pageIdsToClear !== NULL && !is_array($pageIdsToClear)) {
39 $pageIdsToClear = array(intval($pageIdsToClear));
40 }
41 $this->flushPageCache($pageIdsToClear);
42 $this->flushPageSectionCache($pageIdsToClear);
43 }
44
45 /**
46 * Flushes cache_pages or cachingframework_cache_pages.
47 *
48 * @param array|NULL $pageIds pageIds to clear the cache for
49 * @return void
50 */
51 protected function flushPageCache($pageIds = NULL) {
52 $pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
53 if ($pageIds !== NULL) {
54 foreach ($pageIds as $pageId) {
55 $pageCache->flushByTag('pageId_' . $pageId);
56 }
57 } else {
58 $pageCache->flush();
59 }
60 }
61
62 /**
63 * Flushes cache_pagesection or cachingframework_cache_pagesection.
64 *
65 * @param array|NULL $pageIds pageIds to clear the cache for
66 * @return void
67 */
68 protected function flushPageSectionCache($pageIds = NULL) {
69 $pageSectionCache = $GLOBALS['typo3CacheManager']->getCache('cache_pagesection');
70 if ($pageIds !== NULL) {
71 foreach ($pageIds as $pageId) {
72 $pageSectionCache->flushByTag('pageId_' . $pageId);
73 }
74 } else {
75 $pageSectionCache->flush();
76 }
77 }
78
79 }
80
81
82 ?>