TYPO3 CMS  TYPO3_6-2
Cache.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Cache;
3 
17 
23 class Cache {
24 
28  static protected $isCachingFrameworkInitialized = FALSE;
29 
33  static protected $cacheManager;
34 
38  static protected $cacheFactory;
39 
46  static public function initializeCachingFramework() {
47  if (!self::isCachingFrameworkInitialized()) {
48  // New operator used on purpose, makeInstance() is not ready to be used so early in bootstrap
49  self::$cacheManager = new CacheManager();
50  GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', self::$cacheManager);
51  self::$cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
52  // New operator used on purpose, makeInstance() is not ready to be used so early in bootstrap
53  self::$cacheFactory = new CacheFactory('production', self::$cacheManager);
54  GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheFactory', self::$cacheFactory);
55  self::$isCachingFrameworkInitialized = TRUE;
56  }
57  return self::$cacheManager;
58  }
59 
66  static public function isCachingFrameworkInitialized() {
67  return self::$isCachingFrameworkInitialized;
68  }
69 
76  static public function flagCachingFrameworkForReinitialization() {
77  self::$isCachingFrameworkInitialized = FALSE;
78  GeneralUtility::removeSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', self::$cacheManager);
79  GeneralUtility::removeSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheFactory', self::$cacheFactory);
80  self::$cacheManager = NULL;
81  self::$cacheFactory = NULL;
82  }
83 
92  static public function getDatabaseTableDefinitions() {
93  $tableDefinitions = '';
94  foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $cacheName => $_) {
95  $backend = self::$cacheManager->getCache($cacheName)->getBackend();
96  if (method_exists($backend, 'getTableDefinitions')) {
97  $tableDefinitions .= LF . $backend->getTableDefinitions();
98  }
99  }
100  return $tableDefinitions;
101  }
102 
111  public function addCachingFrameworkRequiredDatabaseSchemaToTablesDefinition(array $sqlString, $extensionKey) {
112  self::$cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
113  $sqlString[] = static::getDatabaseTableDefinitions();
114  return array('sqlString' => $sqlString, 'extensionKey' => $extensionKey);
115  }
116 
117 }
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static $isCachingFrameworkInitialized
Definition: Cache.php:28
static removeSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static flagCachingFrameworkForReinitialization()
Definition: Cache.php:76
static isCachingFrameworkInitialized()
Definition: Cache.php:66
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static initializeCachingFramework()
Definition: Cache.php:46
addCachingFrameworkRequiredDatabaseSchemaToTablesDefinition(array $sqlString, $extensionKey)
Definition: Cache.php:111
static getDatabaseTableDefinitions()
Definition: Cache.php:92