JFactory/getCache: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Get a cache object
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
... |
m links |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
===Description=== | ===Description=== | ||
Get a cache object | Get a cache object | ||
===Syntax=== | ===Syntax=== | ||
| Line 66: | Line 60: | ||
</source> | </source> | ||
== See Also == | |||
* [[Using caching to speed up your code]] | |||
* [[API15:JCache]] | |||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=getCache | category=getCache | ||
category=JFactory | category=JFactory | ||
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