Skip to content

Instantly share code, notes, and snippets.

@gartes
Last active June 6, 2018 01:50
Show Gist options
  • Save gartes/7e163f2d33a7e58d11f58f3076dd9c94 to your computer and use it in GitHub Desktop.
Save gartes/7e163f2d33a7e58d11f58f3076dd9c94 to your computer and use it in GitHub Desktop.
JCache кеш
if ( !( $html = $JСache->get( 'action-footer' , 'mododuls' ) ) ) {
jimport('ukcpu.document.document');
jimport('ukcpu.admin.control');
$uDoc = ukcpuDocument::getDocument();
#$module = JModuleHelper::getModules('action-footer');
#$attribs['style'] = 'raw';
#$html = JModuleHelper::renderModule($module[0], $attribs);
// if type html
// minifid - html
$html = $uDoc -> minHtml ( $html ) ;
$JСache->store( $html , 'action-footer' , 'mododuls' );
}
echo $html ;
jimport('joomla.cache.cache');
if (!$this->app)
{
$this->app = JFactory::getApplication();
}
if (!class_exists( 'CacheModelCache' ))
require(JPATH_ROOT .'/administrator/components/com_cache/models/cache.php');
$modelCache = new CacheModelCache();
$allCleared = true ;
$clients = array(1, 0);
foreach ($clients as $client)
{
$mCache = $modelCache->getCache($client);
$clientStr = JText::_($client ? 'JADMINISTRATOR' : 'JSITE') .' > ';
foreach ($mCache->getAll() as $cache)
{
if ($mCache->clean($cache->group) === false)
{
$app->enqueueMessage(JText::sprintf('Ошибка очистки кеша ', $clientStr . $cache->group), 'error');
$allCleared = false;
}
}
}
if ($allCleared)
{
$this->app->enqueueMessage(JText::_('Кеш очищен') , 'message' );
}
else
{
$this->app->enqueueMessage(JText::_('Кеш очищен не полностью'), 'warning');
}
$options = array(
'cachebase' => JPATH_ROOT.DS.'cache' , // кеш папка в корне сайта
'lifetime' => 144000 , // (int) $conf->get('cachetime'), // Врямя жизни кеша
'caching' => true , // принудительное включение кеша
);
$JСache = new JCache($options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment