Actions

API15

JCacheStorage/getInstance

From Joomla! Documentation

< API15:JCacheStorage
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Returns a reference to a cache storage hanlder object, only creating it if it doesn't already exist.

[<! removed edit link to red link >]

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

Syntax

& getInstance($handler= 'file', $options=array())
Parameter Name Default Value Description
$handler 'file' $handler The cache storage handler to instantiate
$options array()

Returns

object A JCacheStorageHandler object

Defined in

libraries/joomla/cache/storage.php

Importing

jimport( 'joomla.cache.storage' );

Source Body

function &getInstance($handler = 'file', $options = array())
{
        static $now = null;
        if(is_null($now)) {
                $now = time();
        }
        $options['now'] = $now;
        //We can't cache this since options may change...
        $handler = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $handler));
        $class   = 'JCacheStorage'.ucfirst($handler);
        if(!class_exists($class))
        {
                $path = dirname(__FILE__).DS.'storage'.DS.$handler.'.php';
                if (file_exists($path) ) {
                        require_once($path);
                } else {
                        return JError::raiseWarning(500, 'Unable to load Cache Storage: '.$handler);
                }
        }
        $return = new $class($options);
        return $return;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />