10 defined(
'JPATH_PLATFORM') or die;
70 public function __construct($options = array())
73 $this->_hash = md5($config->get(
'secret'));
74 $this->_application = (isset($options[
'application'])) ? $options[
'application'] : null;
75 $this->_language = (isset($options[
'language'])) ? $options[
'language'] :
'en-GB';
76 $this->_locking = (isset($options[
'locking'])) ? $options[
'locking'] :
true;
77 $this->_lifetime = (isset($options[
'lifetime'])) ? $options[
'lifetime'] * 60 : $config->get(
'cachetime') * 60;
78 $this->_now = (isset($options[
'now'])) ? $options[
'now'] : time();
82 if (empty($this->_lifetime))
84 $this->_threshold = $this->_now - 60;
85 $this->_lifetime = 60;
89 $this->_threshold = $this->_now - $this->_lifetime;
107 public static function getInstance($handler = null, $options = array())
111 self::addIncludePath(JPATH_PLATFORM .
'/joomla/cache/storage');
113 if (!isset($handler))
116 $handler = $conf->get(
'cache_handler');
119 throw new UnexpectedValueException(
'Cache Storage Handler not set.');
128 $options[
'now'] = $now;
131 $handler = strtolower(preg_replace(
'/[^A-Z0-9_\.-]/i',
'', $handler));
133 $class =
'JCacheStorage' . ucfirst($handler);
134 if (!class_exists($class))
137 jimport(
'joomla.filesystem.path');
138 if ($path =
JPath::find(self::addIncludePath(), strtolower($handler) .
'.php'))
144 throw new RuntimeException(sprintf(
'Unable to load Cache Storage: %s', $handler));
148 return new $class($options);
162 public function get($id, $group, $checkTime =
true)
175 public function getAll()
177 if (!class_exists(
'JCacheStorageHelper',
false))
179 include_once JPATH_PLATFORM .
'/joomla/cache/storage/helper.php';
195 public function store($id, $group, $data)
210 public function remove($id, $group)
227 public function clean($group, $mode = null)
251 public static function isSupported()
264 public static function test()
266 JLog::add(
'JCacheStorage::test() is deprecated. Use JCacheStorage::isSupported() instead.',
JLog::WARNING,
'deprecated');
268 return static::isSupported();
282 public function lock($id, $group, $locktime)
297 public function unlock($id, $group = null)
312 protected function _getCacheId($id, $group)
314 $name = md5($this->_application .
'-' . $id .
'-' . $this->_language);
315 $this->rawname = $this->_hash .
'-' . $name;
316 return $this->_hash .
'-cache-' . $group .
'-' . $name;
329 public static function addIncludePath($path =
'')
338 if (!empty($path) && !in_array($path, $paths))
340 jimport(
'joomla.filesystem.path');