Source for file storage.php
Documentation is available at storage.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Abstract cache storage handler
* @package Joomla.Platform
* @var integer Cache lifetime
* @var string Application name.
* @param array $options Optional parameters
$this->_hash =
md5($config->get('secret'));
$this->_application =
(isset
($options['application'])) ?
$options['application'] :
null;
$this->_language =
(isset
($options['language'])) ?
$options['language'] :
'en-GB';
$this->_locking =
(isset
($options['locking'])) ?
$options['locking'] :
true;
$this->_lifetime =
(isset
($options['lifetime'])) ?
$options['lifetime'] *
60 :
$config->get('cachetime') *
60;
$this->_now =
(isset
($options['now'])) ?
$options['now'] :
time();
// Set time threshold value. If the lifetime is not set, default to 60 (0 is BAD)
// _threshold is now available ONLY as a legacy (it's deprecated). It's no longer used in the core.
$this->_threshold =
$this->_now -
60;
* Returns a cache storage handler object, only creating it
* if it doesn't already exist.
* @param string $handler The cache storage handler to instantiate
* @param array $options Array of handler options
* @return JCacheStorage A JCacheStorage instance
* @throws UnexpectedValueException
* @throws RuntimeException
public static function getInstance($handler =
null, $options =
array())
self::addIncludePath(JPATH_PLATFORM .
'/joomla/cache/storage');
$handler =
$conf->get('cache_handler');
throw
new UnexpectedValueException('Cache Storage Handler not set.');
// We can't cache this since options may change...
$class =
'JCacheStorage' .
ucfirst($handler);
// Search for the class file in the JCacheStorage include paths.
throw
new RuntimeException(sprintf('Unable to load Cache Storage: %s', $handler));
return new $class($options);
* Get cached data by id and group
* @param string $id The cache data id
* @param string $group The cache data group
* @param boolean $checkTime True to verify cache time expiration threshold
* @return mixed Boolean false on failure or a cached data object
public function get($id, $group, $checkTime =
true)
* @return mixed Boolean false on failure or a cached data object
* @todo Review this method. The docblock doesn't fit what it actually does.
* Store the data to cache by id and group
* @param string $id The cache data id
* @param string $group The cache data group
* @param string $data The data to store in cache
* @return boolean True on success, false otherwise
public function store($id, $group, $data)
* Remove a cached data entry by id and group
* @param string $id The cache data id
* @param string $group The cache data group
* @return boolean True on success, false otherwise
public function remove($id, $group)
* Clean cache for a group given a mode.
* @param string $group The cache data group
* @param string $mode The mode for cleaning cache [group|notgroup]
* group mode : cleans all cache in the group
* notgroup mode : cleans all cache not in the group
* @return boolean True on success, false otherwise
public function clean($group, $mode =
null)
* Garbage collect expired cache data
* @return boolean True on success, false otherwise.
* Test to see if the storage handler is available.
* @return boolean True on success, false otherwise
* Test to see if the storage handler is available.
* @return boolean True on success, false otherwise.
* @deprecated 12.3 (Platform) & 4.0 (CMS)
public static function test()
JLog::add('JCacheStorage::test() is deprecated. Use JCacheStorage::isSupported() instead.', JLog::WARNING, 'deprecated');
return static::isSupported();
* @param string $id The cache data id
* @param string $group The cache data group
* @param integer $locktime Cached item max lock time
* @return boolean True on success, false otherwise.
public function lock($id, $group, $locktime)
* @param string $id The cache data id
* @param string $group The cache data group
* @return boolean True on success, false otherwise.
public function unlock($id, $group =
null)
* Get a cache_id string from an id/group pair
* @param string $id The cache data id
* @param string $group The cache data group
* @return string The cache_id string
return $this->_hash .
'-cache-' .
$group .
'-' .
$name;
* Add a directory where JCacheStorage should search for handlers. You may
* either pass a string or an array of directories.
* @param string $path A path to search.
* @return array An array with directory elements
if (!empty($path) &&
!in_array($path, $paths))
Documentation generated on Tue, 19 Nov 2013 15:14:21 +0100 by phpDocumentor 1.4.3