Added feature 9505: Make the caches in TYPO3 use the new caching framework
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_cache.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2008 Ingo Renner <ingo@typo3.org>
6 * All rights reserved
7 *
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.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
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.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 require_once(PATH_t3lib . 'interfaces/interface.t3lib_singleton.php');
26
27 /**
28 * A cache handling helper class
29 *
30 * @author Ingo Renner <ingo@typo3.org>
31 * @package TYPO3
32 * @subpackage t3lib
33 */
34 class t3lib_cache {
35
36 /**
37 * initializes the cache_pages cache
38 *
39 * @return void
40 * @author Ingo Renner <ingo@typo3.org>
41 */
42 public static function initPageCache() {
43 try {
44 $GLOBALS['typo3CacheFactory']->create(
45 'cache_pages',
46 't3lib_cache_VariableCache',
47 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackendAssignments']['cache_pages']['backend'],
48 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackendAssignments']['cache_pages']['options']
49 );
50 } catch(t3lib_cache_exception_DuplicateIdentifier $e) {
51 // do nothing, a cache_pages cache already exists
52 }
53 }
54
55 /**
56 * initializes the cache_pagesection cache
57 *
58 * @return void
59 * @author Ingo Renner <ingo@typo3.org>
60 */
61 public static function initPageSectionCache() {
62 try {
63 $GLOBALS['typo3CacheFactory']->create(
64 'cache_pagesection',
65 't3lib_cache_VariableCache',
66 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackendAssignments']['cache_pagesection']['backend'],
67 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackendAssignments']['cache_pagesection']['options']
68 );
69 } catch(t3lib_cache_exception_DuplicateIdentifier $e) {
70 // do nothing, a cache_pagesection cache already exists
71 }
72 }
73
74 /**
75 * initializes the cache_hash cache
76 *
77 * @return void
78 * @author Ingo Renner <ingo@typo3.org>
79 */
80 public static function initContentHashCache() {
81 try {
82 $GLOBALS['typo3CacheFactory']->create(
83 'cache_hash',
84 't3lib_cache_VariableCache',
85 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackendAssignments']['cache_hash']['backend'],
86 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackendAssignments']['cache_hash']['options']
87 );
88 } catch(t3lib_cache_exception_DuplicateIdentifier $e) {
89 // do nothing, a cache_hash cache already exists
90 }
91 }
92 }
93
94
95 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_cache.php']) {
96 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_cache.php']);
97 }
98
99 ?>