|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010 Extbase Team 00006 * All rights reserved 00007 * 00008 * This class is a backport of the corresponding class of FLOW3. 00009 * All credits go to the v5 team. 00010 * 00011 * This script is part of the TYPO3 project. The TYPO3 project is 00012 * free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * The GNU General Public License can be found at 00018 * http://www.gnu.org/copyleft/gpl.html. 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * Simple Cache for classInfos 00030 * 00031 * @author Daniel Pötzinger 00032 */ 00033 class Tx_Extbase_Object_Container_ClassInfoCache { 00034 00035 /** 00036 * 00037 * @var array 00038 */ 00039 private $level1Cache=array(); 00040 00041 /** 00042 * 00043 * @var t3lib_cache_frontend_VariableFrontend 00044 */ 00045 private $level2Cache; 00046 00047 /** 00048 * constructor 00049 */ 00050 public function __construct() { 00051 $this->initializeLevel2Cache(); 00052 } 00053 00054 /** 00055 * checks if cacheentry exists for id 00056 * @param string $id 00057 */ 00058 public function has($id) { 00059 return isset($this->level1Cache[$id]) || $this->level2Cache->has($id); 00060 } 00061 00062 /** 00063 * Gets the cache for the id 00064 * @param string $id 00065 */ 00066 public function get($id) { 00067 if (!isset($this->level1Cache[$id])) { 00068 $this->level1Cache[$id] = $this->level2Cache->get($id); 00069 } 00070 return $this->level1Cache[$id]; 00071 } 00072 00073 /** 00074 * sets the cache for the id 00075 * 00076 * @param $id 00077 * @param $value 00078 */ 00079 public function set($id,$value) { 00080 $this->level1Cache[$id]=$value; 00081 $this->level2Cache->set($id,$value); 00082 } 00083 00084 00085 /** 00086 * Initialize the TYPO3 second level cache 00087 */ 00088 private function initializeLevel2Cache() { 00089 t3lib_cache::initializeCachingFramework(); 00090 try { 00091 $this->level2Cache = $GLOBALS['typo3CacheManager']->getCache('cache_extbase_object'); 00092 } catch (t3lib_cache_exception_NoSuchCache $exception) { 00093 $this->level2Cache = $GLOBALS['typo3CacheFactory']->create( 00094 'cache_extbase_object', 00095 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_extbase_object']['frontend'], 00096 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_extbase_object']['backend'], 00097 $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['cache_extbase_object']['options'] 00098 ); 00099 } 00100 } 00101 }
1.8.0