10 defined(
'JPATH_PLATFORM') or die;
44 public function __construct($options)
46 $this->cache =
new JCache($options);
47 $this->options = & $this->cache->_options;
50 foreach ($options as $option => $value)
52 if (isset($options[$option]))
54 $this->options[$option] = $options[$option];
69 public function __call($name, $arguments)
71 $nazaj = call_user_func_array(array($this->cache, $name), $arguments);
86 public static function getInstance($type =
'output', $options = array())
88 self::addIncludePath(JPATH_PLATFORM .
'/joomla/cache/controller');
90 $type = strtolower(preg_replace(
'/[^A-Z0-9_\.-]/i',
'', $type));
92 $class =
'JCacheController' . ucfirst($type);
94 if (!class_exists($class))
97 jimport(
'joomla.filesystem.path');
99 if ($path =
JPath::find(self::addIncludePath(), strtolower($type) .
'.php'))
105 throw new RuntimeException(
'Unable to load Cache Controller: ' . $type, 500);
109 return new $class($options);
121 public function setCaching($enabled)
123 $this->cache->setCaching($enabled);
135 public function setLifeTime($lt)
137 $this->cache->setLifeTime($lt);
150 public static function addIncludePath($path =
'')
158 if (!empty($path) && !in_array($path, $paths))
160 jimport(
'joomla.filesystem.path');
176 public function get($id, $group = null)
178 $data = $this->cache->get($id, $group);
182 $locktest =
new stdClass;
183 $locktest->locked = null;
184 $locktest->locklooped = null;
185 $locktest = $this->cache->lock($id, $group);
186 if ($locktest->locked ==
true && $locktest->locklooped ==
true)
188 $data = $this->cache->get($id, $group);
190 if ($locktest->locked ==
true)
192 $this->cache->unlock($id, $group);
200 $data = unserialize(trim($data));
217 public function store($data, $id, $group = null, $wrkarounds =
true)
219 $locktest =
new stdClass;
220 $locktest->locked = null;
221 $locktest->locklooped = null;
223 $locktest = $this->cache->lock($id, $group);
225 if ($locktest->locked ==
false && $locktest->locklooped ==
true)
227 $locktest = $this->cache->lock($id, $group);
230 $sucess = $this->cache->store(serialize($data), $id, $group);
232 if ($locktest->locked ==
true)
234 $this->cache->unlock($id, $group);