JCache/getInstance
From Joomla! Documentation
< API16:JCacheRevision as of 21:52, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
Revision as of 21:52, 12 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Returns a reference to a cache adapter object, always creating it
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
getInstance($type= 'output', $options=array())
Parameter Name | Default Value | Description |
---|---|---|
$type | 'output' | $type The cache object type to instantiate |
$options | array() |
Returns[edit]
object A object
Defined in[edit]
libraries/joomla/cache/cache.php
Importing[edit]
jimport( 'joomla.cache.cache' );
Source Body[edit]
function getInstance($type = 'output', $options = array())
{
$type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type));
$class = 'JCache'.ucfirst($type);
if (!class_exists($class))
{
$path = dirname(__FILE__).DS.'handler'.DS.$type.'.php';
if (file_exists($path)) {
require_once $path;
} else {
JError::raiseError(500, 'Unable to load Cache Handler: '.$type);
}
}
return new $class($options);
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />