|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010 Xavier Perseguers <typo3@perseguers.ch> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 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 /** 00030 * Cache engine helper for generated queries. 00031 * 00032 * $Id$ 00033 * 00034 * @author Xavier Perseguers <typo3@perseguers.ch> 00035 * @package TYPO3 00036 * @subpackage dbal 00037 */ 00038 class tx_dbal_querycache { 00039 00040 /** 00041 * Initializes the caching framework by loading the cache manager and factory 00042 * into the global context. 00043 * 00044 * @return void 00045 */ 00046 public static function initializeCachingFramework() { 00047 t3lib_cache::initializeCachingFramework(); 00048 } 00049 00050 /** 00051 * Initializes the DBAL cache. 00052 * 00053 * @return void 00054 */ 00055 public static function initDbalCache() { 00056 try { 00057 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal'])) { 00058 $backend = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal']['backend']; 00059 $options = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal']['options']; 00060 } else { 00061 // Transient storage, will be better than nothing 00062 $backend = 't3lib_cache_backend_TransientMemoryBackend'; 00063 $options = array(); 00064 } 00065 00066 $GLOBALS['typo3CacheFactory']->create( 00067 'dbal', 00068 't3lib_cache_frontend_VariableFrontend', 00069 $backend, 00070 $options 00071 ); 00072 } catch (t3lib_cache_exception_DuplicateIdentifier $e) { 00073 // Do nothing, a DBAL cache already exists 00074 } 00075 } 00076 00077 /** 00078 * Returns a proper cache key. 00079 * 00080 * @param mixed $config 00081 * @return void 00082 */ 00083 public static function getCacheKey($config) { 00084 if (is_array($config)) { 00085 return md5(serialize($config)); 00086 } else { 00087 return $config; 00088 } 00089 } 00090 } 00091 00092 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/dbal/lib/class.tx_dbal_querycache.php'])) { 00093 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/dbal/lib/class.tx_dbal_querycache.php']); 00094 } 00095 00096 ?>
1.8.0