API16

JCache/getInstance: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Returns a reference to a cache adapter object, always creating it <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JCache/getInstanc...
 
m preparing for archive only
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
Returns a reference to a cache adapter object, always creating it
Returns a reference to a cache adapter object, always creating it


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JCache/getInstance|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JCache/getInstance}}
 
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 57: Line 55:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JCache/getInstance|Edit See Also]]<nowiki>]</nowiki>
<! removed transcluded page call, red link never existed >
</span>
{{SeeAlso:JCache/getInstance}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=getInstance
  category=getInstance
  category=JCache
  category=JCache
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API16]]

Latest revision as of 01:21, 25 March 2017

Description

Returns a reference to a cache adapter object, always creating it


<! removed transcluded page call, red link never existed >

Syntax

getInstance($type= 'output', $options=array())
Parameter Name Default Value Description
$type 'output' $type The cache object type to instantiate
$options array()

Returns

object A object

Defined in

libraries/joomla/cache/cache.php

Importing

jimport( 'joomla.cache.cache' );

Source Body

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 transcluded page call, red link never existed >

Examples

Code Examples