API15

JFactory/getCache: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Get a cache object <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> ...
 
Tom Hutchison (talk | contribs)
m links
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
===Description===
===Description===
Get a cache object
Get a cache object
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JFactory/getCache|Edit Descripton]]<nowiki>]</nowiki>
</span>
{{Description:JFactory/getCache}}


===Syntax===
===Syntax===
Line 66: Line 60:
</source>
</source>


<span class="editsection" style="font-size:76%;">
== See Also ==
<nowiki>[</nowiki>[[SeeAlso:JFactory/getCache|Edit See Also]]<nowiki>]</nowiki>
* [[Using caching to speed up your code]]
</span>
* [[API15:JCache]]
{{SeeAlso:JFactory/getCache}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=getCache
  category=getCache
  category=JFactory
  category=JFactory
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 12:55, 25 March 2017

Description

Get a cache object

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;
}

See Also

Examples

Code Examples