mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-22 05:15:29 +09:00
Cache layouts to save two queries per page view
This commit is contained in:
parent
85396efcf9
commit
36558f303a
2 changed files with 14 additions and 1 deletions
|
|
@ -259,6 +259,7 @@ class layoutAdminController extends layout
|
||||||
$oLayoutModel = getModel('layout');
|
$oLayoutModel = getModel('layout');
|
||||||
$cache_file = $oLayoutModel->getUserLayoutCache($args->layout_srl, Context::getLangType());
|
$cache_file = $oLayoutModel->getUserLayoutCache($args->layout_srl, Context::getLangType());
|
||||||
FileHandler::removeFile($cache_file);
|
FileHandler::removeFile($cache_file);
|
||||||
|
Rhymix\Framework\Cache::delete('layout:' . $args->layout_srl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
|
@ -322,10 +323,13 @@ class layoutAdminController extends layout
|
||||||
|
|
||||||
$layout_file = $oLayoutModel->getUserLayoutHtml($layout_srl);
|
$layout_file = $oLayoutModel->getUserLayoutHtml($layout_srl);
|
||||||
FileHandler::removeFile($layout_file);
|
FileHandler::removeFile($layout_file);
|
||||||
|
|
||||||
// Delete Layout
|
// Delete Layout
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->layout_srl = $layout_srl;
|
$args->layout_srl = $layout_srl;
|
||||||
$output = executeQuery("layout.deleteLayout", $args);
|
$output = executeQuery("layout.deleteLayout", $args);
|
||||||
|
|
||||||
|
Rhymix\Framework\Cache::delete('layout:' . $args->layout_srl);
|
||||||
|
|
||||||
if(!$output->toBool()) return $output;
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,13 @@ class layoutModel extends layout
|
||||||
*/
|
*/
|
||||||
function getLayout($layout_srl)
|
function getLayout($layout_srl)
|
||||||
{
|
{
|
||||||
|
// Get information from cache
|
||||||
|
$layout_info = Rhymix\Framework\Cache::get("layout:$layout_srl");
|
||||||
|
if ($layout_info !== null)
|
||||||
|
{
|
||||||
|
return $layout_info;
|
||||||
|
}
|
||||||
|
|
||||||
// Get information from the DB
|
// Get information from the DB
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
$args->layout_srl = $layout_srl;
|
$args->layout_srl = $layout_srl;
|
||||||
|
|
@ -267,6 +274,8 @@ class layoutModel extends layout
|
||||||
// Return xml file informaton after listing up the layout and extra_vars
|
// Return xml file informaton after listing up the layout and extra_vars
|
||||||
$layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type);
|
$layout_info = $this->getLayoutInfo($layout, $output->data, $output->data->layout_type);
|
||||||
|
|
||||||
|
// Store in cache
|
||||||
|
Rhymix\Framework\Cache::set("layout:$layout_srl", $layout_info);
|
||||||
return $layout_info;
|
return $layout_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -484,7 +493,7 @@ class layoutModel extends layout
|
||||||
{
|
{
|
||||||
$cache_file = $this->getUserLayoutCache($layout_srl, Context::getLangType());
|
$cache_file = $this->getUserLayoutCache($layout_srl, Context::getLangType());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($cache_file)&&filemtime($cache_file)>filemtime($xml_file))
|
if(file_exists($cache_file)&&filemtime($cache_file)>filemtime($xml_file))
|
||||||
{
|
{
|
||||||
include($cache_file);
|
include($cache_file);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue