API15

API15:JFactory/getCache

From Joomla! Documentation

Revision as of 22:20, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Get a cache object <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

Get a cache object

[Edit Descripton]

Template:Description:JFactory/getCache

Syntax

& getCache($group= '', $handler= 'callback', $storage=null)
Parameter Name Default Value Description
$group The cache group name
$handler 'callback' The handler to use
$storage null The storage method

Returns

object

Defined in

libraries/joomla/factory.php

Importing

jimport( 'joomla.factory' );

Source Body

function &getCache($group = '', $handler = 'callback', $storage = null)
{
        $handler = ($handler == 'function') ? 'callback' : $handler;

        $conf =& JFactory::getConfig();

        if(!isset($storage)) {
                $storage = $conf->getValue('config.cache_handler', 'file');
        }

        $options = array(
                'defaultgroup'  => $group,
                'cachebase'     => $conf->getValue('config.cache_path'),
                'lifetime'              => $conf->getValue('config.cachetime') * 60,    // minutes to seconds
                'language'              => $conf->getValue('config.language'),
                'storage'               => $storage
        );

        jimport('joomla.cache.cache');

        $cache =& JCache::getInstance( $handler, $options );
        $cache->setCaching($conf->getValue('config.caching'));
        return $cache;
}

[Edit See Also] Template:SeeAlso:JFactory/getCache

Examples

<CodeExamplesForm />