| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $id:$ 4 * @package Joomla.Framework 5 * @subpackage Cache 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // Check to ensure this file is within the rest of the framework 16 defined('JPATH_BASE') or die(); 17 18 /** 19 * XCache cache storage handler 20 * 21 * @package Joomla.Framework 22 * @subpackage Cache 23 * @since 1.5 24 */ 25 class JCacheStorageXCache extends JCacheStorage 26 { 27 /** 28 * Constructor 29 * 30 * @access protected 31 * @param array $options optional parameters 32 */ 33 function __construct( $options = array() ) 34 { 35 parent::__construct($options); 36 37 $config =& JFactory::getConfig(); 38 $this->_hash = $config->getValue('config.secret'); 39 } 40 41 /** 42 * Get cached data by id and group 43 * 44 * @access public 45 * @param string $id The cache data id 46 * @param string $group The cache data group 47 * @param boolean $checkTime True to verify cache time expiration threshold 48 * @return mixed Boolean false on failure or a cached data string 49 * @since 1.5 50 */ 51 function get($id, $group, $checkTime) 52 { 53 $cache_id = $this->_getCacheId($id, $group); 54 55 //check if id exists 56 if( !xcache_isset( $cache_id ) ){ 57 return false; 58 } 59 60 return xcache_get($cache_id); 61 } 62 63 /** 64 * Store the data by id and group 65 * 66 * @access public 67 * @param string $id The cache data id 68 * @param string $group The cache data group 69 * @param string $data The data to store in cache 70 * @return boolean True on success, false otherwise 71 * @since 1.5 72 */ 73 function store($id, $group, $data) 74 { 75 $cache_id = $this->_getCacheId($id, $group); 76 return xcache_set($cache_id, $data, $this->_lifetime); 77 } 78 79 /** 80 * Remove a cached data entry by id and group 81 * 82 * @access public 83 * @param string $id The cache data id 84 * @param string $group The cache data group 85 * @return boolean True on success, false otherwise 86 * @since 1.5 87 */ 88 function remove($id, $group) 89 { 90 $cache_id = $this->_getCacheId($id, $group); 91 92 if( !xcache_isset( $cache_id ) ){ 93 return true; 94 } 95 96 return xcache_unset($cache_id); 97 } 98 99 /** 100 * Clean cache for a group given a mode. 101 * 102 * group mode : cleans all cache in the group 103 * notgroup mode : cleans all cache not in the group 104 * 105 * @access public 106 * @param string $group The cache data group 107 * @param string $mode The mode for cleaning cache [group|notgroup] 108 * @return boolean True on success, false otherwise 109 * @since 1.5 110 */ 111 function clean($group, $mode) 112 { 113 return true; 114 } 115 116 /** 117 * Test to see if the cache storage is available. 118 * 119 * @static 120 * @access public 121 * @return boolean True on success, false otherwise. 122 */ 123 function test() 124 { 125 return (extension_loaded('xcache')); 126 } 127 128 /** 129 * Get a cache_id string from an id/group pair 130 * 131 * @access private 132 * @param string $id The cache data id 133 * @param string $group The cache data group 134 * @return string The cache_id string 135 * @since 1.5 136 */ 137 function _getCacheId($id, $group) 138 { 139 $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); 140 return 'cache_'.$group.'-'.$name; 141 } 142 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |