mirror of
https://github.com/e107inc/e107.git
synced 2025-07-30 19:30:25 +02:00
Added new System Cache in addition to the regular cache. System cache will contain only system config type info and no real page content, that will still be handled by the regular cache
This commit is contained in:
16
class2.php
16
class2.php
@@ -11,9 +11,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/class2.php,v $
|
||||
| $Revision: 1.11 $
|
||||
| $Date: 2007-02-03 12:43:53 $
|
||||
| $Author: e107steved $
|
||||
| $Revision: 1.12 $
|
||||
| $Date: 2007-02-04 17:36:16 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
//
|
||||
@@ -267,7 +267,7 @@ e107_require_once(e_HANDLER.'cache_handler.php');
|
||||
e107_require_once(e_HANDLER.'arraystorage_class.php');
|
||||
$eArrayStorage = new ArrayData();
|
||||
|
||||
$PrefCache = ecache::retrieve('SitePrefs', 24 * 60, true);
|
||||
$PrefCache = ecache::retrieve_sys('SitePrefs', 24 * 60, true);
|
||||
if(!$PrefCache){
|
||||
// No cache of the prefs array, going for the db copy..
|
||||
$retrieve_prefs[] = 'SitePrefs';
|
||||
@@ -311,7 +311,7 @@ if(!$PrefCache){
|
||||
// write pref cache array
|
||||
$PrefCache = $eArrayStorage->WriteArray($pref, false);
|
||||
// store the prefs in cache if cache is enabled
|
||||
ecache::set('SitePrefs', $PrefCache);
|
||||
ecache::set_sys('SitePrefs', $PrefCache);
|
||||
} else {
|
||||
// cache of core prefs was found, so grab all the useful core rows we need
|
||||
if(!isset($sysprefs->DefaultIgnoreRows)){
|
||||
@@ -715,7 +715,7 @@ define("TIMEOFFSET", $e_deltaTime);
|
||||
|
||||
$sql->db_Mark_Time('Start: Get menus');
|
||||
|
||||
$menu_data = $e107cache->retrieve("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE));
|
||||
$menu_data = $e107cache->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE));
|
||||
$menu_data = $eArrayStorage->ReadArray($menu_data);
|
||||
$eMenuList=array();
|
||||
$eMenuActive=array();
|
||||
@@ -729,7 +729,7 @@ if(!is_array($menu_data)) {
|
||||
$menu_data['menu_list'] = $eMenuList;
|
||||
$menu_data['menu_active'] = $eMenuActive;
|
||||
$menu_data = $eArrayStorage->WriteArray($menu_data, false);
|
||||
$e107cache->set("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE), $menu_data);
|
||||
$e107cache->set_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE), $menu_data);
|
||||
unset($menu_data);
|
||||
} else {
|
||||
$eMenuList = $menu_data['menu_list'];
|
||||
@@ -1030,7 +1030,7 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
|
||||
$msqlPrefCache = $eArrayStorage->WriteArray($_pref);
|
||||
$sql->db_Select_gen("INSERT INTO #core (e107_name,e107_value) values ('SitePrefs', '{$msqlPrefCache}')
|
||||
ON DUPLICATE KEY UPDATE e107_value='{$msqlPrefCache}'");
|
||||
ecache::clear('SitePrefs');
|
||||
ecache::clear_sys('SitePrefs');
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $
|
||||
| $Revision: 1.1.1.1 $
|
||||
| $Date: 2006-12-02 04:33:12 $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2007-02-04 17:36:16 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -27,54 +27,81 @@ require_once(e_HANDLER."cache_handler.php");
|
||||
$ec = new ecache;
|
||||
if ($pref['cachestatus'] == '2') {
|
||||
$pref['cachestatus'] = '1';
|
||||
save_prefs();
|
||||
}
|
||||
if (isset($_POST['submit_cache'])) {
|
||||
if ($pref['cachestatus'] != $_POST['cachestatus']) {
|
||||
|
||||
if(!is_writable(e_BASE.$FILES_DIRECTORY.'cache/'))
|
||||
{
|
||||
$ns->tablerender(CACLAN_3, CACLAN_10);
|
||||
require_once("footer.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['submit_cache']))
|
||||
{
|
||||
if ($pref['cachestatus'] != $_POST['cachestatus'] || $pref['syscachestatus'] != $_POST['syscachestatus'])
|
||||
{
|
||||
$pref['cachestatus'] = $_POST['cachestatus'];
|
||||
$pref['syscachestatus'] = $_POST['syscachestatus'];
|
||||
save_prefs();
|
||||
$ec->clear();
|
||||
$ec->clear_sys();
|
||||
$update = true;
|
||||
admin_update($update, 'update', CACLAN_4);
|
||||
}
|
||||
admin_update($update, 'update', CACLAN_4);
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['empty_syscache'])) {
|
||||
$ec->clear_sys();
|
||||
$ns->tablerender(LAN_UPDATE, "<div style='text-align:center'><b>".CACLAN_15."</b></div>");
|
||||
}
|
||||
|
||||
if (isset($_POST['empty_cache'])) {
|
||||
$ec->clear();
|
||||
$ns->tablerender(LAN_UPDATE, "<div style='text-align:center'><b>".CACLAN_6."</b></div>");
|
||||
}
|
||||
|
||||
$syscache_files = glob($e107->file_path.$FILES_DIRECTORY."cache/S_*.*");
|
||||
$cache_files = glob($e107->file_path.$FILES_DIRECTORY."cache/C_*.*");
|
||||
|
||||
$syscache_files_num = count($syscache_files);
|
||||
$cache_files_num = count($cache_files);
|
||||
|
||||
$sys_count = CACLAN_17." ".$syscache_files_num." ".($syscache_files_num != 1 ? CACLAN_19 : CACLAN_18);
|
||||
$nonsys_count = CACLAN_17." ".$cache_files_num." ".($cache_files_num != 1 ? CACLAN_19 : CACLAN_18);
|
||||
|
||||
$text = "<div style='text-align:center'>
|
||||
<form method='post' action='".e_SELF."'>
|
||||
<table style='".ADMIN_WIDTH."' class='fborder'>
|
||||
<tr>
|
||||
<td class='fcaption'>".CACLAN_1."</td>
|
||||
<td colspan='2' class='fcaption'>".CACLAN_1."</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='forumheader3'>";
|
||||
$text .= (!$pref['cachestatus']) ? "<input type='radio' name='cachestatus' value='0' checked='checked' />" :
|
||||
"<input type='radio' name='cachestatus' value='0' />";
|
||||
$text .= CACLAN_7."
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3' style='width:50%;'>".CACLAN_11.": <div class='smalltext'>".CACLAN_13."</div><br />{$nonsys_count}</td>
|
||||
<td class='forumheader3' style='width:50%'>
|
||||
<input type='radio' name='cachestatus' value='1'".($pref['cachestatus'] ? " checked='checked'" : "")." /> ".LAN_ENABLED."
|
||||
<input type='radio' name='cachestatus' value='0'".(!$pref['cachestatus'] ? " checked='checked'" : "")." /> ".LAN_DISABLED."
|
||||
<input class='button' type='submit' name='empty_cache' value='".CACLAN_5."' />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class='forumheader3'>";
|
||||
if (is_writable(e_FILE."cache")) {
|
||||
$text .= ('1' == $pref['cachestatus']) ? "<input type='radio' name='cachestatus' value='1' checked='checked' />" :
|
||||
"<input type='radio' name='cachestatus' value='1' />";
|
||||
$text .= CACLAN_9;
|
||||
} else {
|
||||
$text .= CACLAN_9."<br /><br /><b>".CACLAN_10."</b>";
|
||||
}
|
||||
$text .= "</td>
|
||||
<td class='forumheader3' style='width:50%;'>".CACLAN_12.": <div class='smalltext'>".CACLAN_14."</div><br />{$sys_count}</td>
|
||||
<td class='forumheader3' style='width:50%'>
|
||||
<input type='radio' name='syscachestatus' value='1'".($pref['syscachestatus'] ? " checked='checked'" : "")." /> ".LAN_ENABLED."
|
||||
<input type='radio' name='syscachestatus' value='0'".(!$pref['syscachestatus'] ? " checked='checked'" : "")." /> ".LAN_DISABLED."
|
||||
<input class='button' type='submit' name='empty_syscache' value='".CACLAN_16."' />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr style='vertical-align:top'>
|
||||
<td style='text-align:center' class='forumheader'>
|
||||
|
||||
<td colspan='2' style='text-align:center' class='forumheader'>
|
||||
<br />
|
||||
<input class='button' type='submit' name='submit_cache' value='".CACLAN_2."' />
|
||||
<input class='button' type='submit' name='empty_cache' value='".CACLAN_5."' />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@@ -12,8 +12,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/cache_handler.php,v $
|
||||
| $Revision: 1.1.1.1 $
|
||||
| $Date: 2006-12-02 04:33:42 $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2007-02-04 17:36:16 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -24,7 +24,7 @@ if (!defined('e107_INIT')) { exit; }
|
||||
* Class to cache data as files, improving site speed and throughput.
|
||||
*
|
||||
* @package e107
|
||||
* @version $Revision: 1.1.1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
* @author $Author: mcfly_e107 $
|
||||
*/
|
||||
class ecache {
|
||||
@@ -39,7 +39,8 @@ class ecache {
|
||||
* @scope private
|
||||
* If the tag begins 'menu_', e_QUERY is not included in the hash which creates the file name
|
||||
*/
|
||||
function cache_fname($CacheTag) {
|
||||
function cache_fname($CacheTag, $syscache = false)
|
||||
{
|
||||
global $FILES_DIRECTORY;
|
||||
if(strpos($CacheTag, "nomd5_") === 0) {
|
||||
// Add 'nomd5' to indicate we are not calculating an md5
|
||||
@@ -68,8 +69,9 @@ class ecache {
|
||||
} else {
|
||||
$CheckTag = '';
|
||||
}
|
||||
$q = preg_replace("#\W#", "_", $CacheTag);
|
||||
$q = ($syscache ? "S_" : "C_").preg_replace("#\W#", "_", $CacheTag);
|
||||
$fname = './'.e_BASE.$FILES_DIRECTORY.'cache/'.$q.$CheckTag.'.cache.php';
|
||||
//echo "cache f_name = $fname <br />";
|
||||
return $fname;
|
||||
}
|
||||
|
||||
@@ -80,10 +82,11 @@ class ecache {
|
||||
* @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query.
|
||||
* @scope public
|
||||
*/
|
||||
function retrieve($CacheTag, $MaximumAge = false, $ForcedCheck = false) {
|
||||
function retrieve($CacheTag, $MaximumAge = false, $ForcedCheck = false, $syscache = false) {
|
||||
global $pref, $FILES_DIRECTORY, $tp;
|
||||
if (($pref['cachestatus'] || $ForcedCheck == true) && !$tp->checkHighlighting()) {
|
||||
$cache_file = (isset($this) ? $this->cache_fname($CacheTag) : ecache::cache_fname($CacheTag));
|
||||
if(($syscache == false && varsettrue($pref['cachestatus'])) || ($syscache == true && varsettrue($pref['syscachestatus'])) && !$tp->checkHighlighting())
|
||||
{
|
||||
$cache_file = (isset($this) ? $this->cache_fname($CacheTag, $syscache) : ecache::cache_fname($CacheTag, $syscache));
|
||||
if (file_exists($cache_file)) {
|
||||
if ($MaximumAge != false && (filemtime($cache_file) + ($MaximumAge * 60)) < time()) {
|
||||
unlink($cache_file);
|
||||
@@ -100,6 +103,26 @@ class ecache {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @param string $query
|
||||
* @param int $MaximumAge the time in minutes before the cache file 'expires'
|
||||
* @desc Returns the data from the cache file associated with $query, else it returns false if there is no cache for $query.
|
||||
* @scope public
|
||||
*/
|
||||
function retrieve_sys($CacheTag, $MaximumAge = false, $ForcedCheck = false)
|
||||
{
|
||||
if(isset($this))
|
||||
{
|
||||
return $this->retrieve($CacheTag, $MaximumAge, $ForcedCheck, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ecache::retrieve($CacheTag, $MaximumAge, $ForcedCheck, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @param string $CacheTag - name of tag for future retrieval
|
||||
@@ -109,29 +132,69 @@ class ecache {
|
||||
* @desc Creates / overwrites the cache file for $query, $text is the data to store for $query.
|
||||
* @scope public
|
||||
*/
|
||||
function set($CacheTag, $Data, $ForceCache = false, $bRaw=0) {
|
||||
function set($CacheTag, $Data, $ForceCache = false, $bRaw=0, $syscache = false) {
|
||||
global $pref, $FILES_DIRECTORY, $tp;
|
||||
if (($pref['cachestatus'] || $ForceCache == true) && !$tp->checkHighlighting()) {
|
||||
$cache_file = (isset($this) ? $this->cache_fname($CacheTag) : ecache::cache_fname($CacheTag));
|
||||
if(($syscache == false && varsettrue($pref['cachestatus'])) || ($syscache == true && varsettrue($pref['syscachestatus'])) && !$tp->checkHighlighting())
|
||||
{
|
||||
$cache_file = (isset($this) ? $this->cache_fname($CacheTag, $syscache) : ecache::cache_fname($CacheTag, $syscache));
|
||||
file_put_contents($cache_file, ($bRaw? $Data : '<?php'.$Data) );
|
||||
@chmod($cache_file, 0777);
|
||||
@touch($cache_file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @param string $CacheTag - name of tag for future retrieval
|
||||
* @param string $Data - data to be cached
|
||||
* @param bool $ForceCache (optional, default false) - if TRUE, writes cache even when disabled
|
||||
* @param bool $bRaw (optional, default false) - if TRUE, writes data exactly as provided instead of prefacing with php leadin
|
||||
* @desc Creates / overwrites the cache file for $query, $text is the data to store for $query.
|
||||
* @scope public
|
||||
*/
|
||||
function set_sys($CacheTag, $Data, $ForceCache = false, $bRaw=0)
|
||||
{
|
||||
if(isset($this))
|
||||
{
|
||||
return $this->set($CacheTag, $Data, $ForceCache, $bRaw, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecache::set($CacheTag, $Data, $ForceCache, $bRaw, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @param string $CacheTag
|
||||
* @desc Deletes cache files. If $query is set, deletes files named {$CacheTag}*.cache.php, if not it deletes all cache files - (*.cache.php)
|
||||
*/
|
||||
function clear($CacheTag = '') {
|
||||
function clear($CacheTag = '', $syscache = false) {
|
||||
global $pref, $FILES_DIRECTORY;
|
||||
$file = ($CacheTag) ? preg_replace("#\W#", "_", $CacheTag)."*.cache.php" : "*.cache.php";
|
||||
$dir = "./".e_BASE.$FILES_DIRECTORY."cache/";
|
||||
$ret = ecache::delete($dir, $file);
|
||||
$ret = ecache::delete($dir, $file, $syscache);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @param string $CacheTag
|
||||
* @desc Deletes cache files. If $query is set, deletes files named {$CacheTag}*.cache.php, if not it deletes all cache files - (*.cache.php)
|
||||
*/
|
||||
function clear_sys($CacheTag = '')
|
||||
{
|
||||
if(isset($this))
|
||||
{
|
||||
return $this->clear($CacheTag, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecache::clear($CacheTag, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @param string $dir
|
||||
@@ -139,8 +202,9 @@ class ecache {
|
||||
* @desc Internal class function to allow deletion of cache files using a pattern, default '*.*'
|
||||
* @scope private
|
||||
*/
|
||||
function delete($dir, $pattern = "*.*") {
|
||||
function delete($dir, $pattern = "*.*", $syscache = false) {
|
||||
$deleted = false;
|
||||
$pattern = ($syscache ? "S_" : "C_").$pattern;
|
||||
$pattern = str_replace(array("\*", "\?"), array(".*", "."), preg_quote($pattern));
|
||||
if (substr($dir, -1) != "/") {
|
||||
$dir .= "/";
|
||||
|
@@ -12,9 +12,9 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2006-12-05 09:15:05 $
|
||||
| $Author: mrpete $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2007-02-04 17:36:16 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -169,9 +169,9 @@ class e_shortcode {
|
||||
$cur_shortcodes = array();
|
||||
if($type == 'file')
|
||||
{
|
||||
$batch_cachefile = "nomd5_".md5($fname);
|
||||
$batch_cachefile = "nomd5_scbatch_".md5($fname);
|
||||
// $cache_filename = $e107cache->cache_fname("nomd5_{$batchfile_md5}");
|
||||
$sc_cache = $e107cache->retrieve($batch_cachefile);
|
||||
$sc_cache = $e107cache->retrieve_sys($batch_cachefile);
|
||||
if(!$sc_cache)
|
||||
{
|
||||
$sc_batch = file($fname);
|
||||
@@ -209,7 +209,7 @@ class e_shortcode {
|
||||
if($type == 'file')
|
||||
{
|
||||
$sc_cache = $eArrayStorage->WriteArray($cur_shortcodes, false);
|
||||
$e107cache->set($batch_cachefile, $sc_cache);
|
||||
$e107cache->set_sys($batch_cachefile, $sc_cache);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,8 +4,8 @@
|
||||
| e107 website system - Language File.
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_cache.php,v $
|
||||
| $Revision: 1.1.1.1 $
|
||||
| $Date: 2006-12-02 04:34:40 $
|
||||
| $Revision: 1.2 $
|
||||
| $Date: 2007-02-04 17:36:16 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -16,8 +16,17 @@ define("CACLAN_4", "Cache status set");
|
||||
define("CACLAN_5", "Empty Cache");
|
||||
define("CACLAN_6", "Cache Emptied");
|
||||
|
||||
define("CACLAN_7", "Cache Disabled");
|
||||
// define("CACLAN_8", "Cache data saved to MySQL");
|
||||
define("CACLAN_9", "Cache data saved to disk file");
|
||||
define("CACLAN_10", "The cache directory is not writable. Please ensure this directory is set CHMOD 0777");
|
||||
|
||||
define("CACLAN_11", "Content Cache");
|
||||
define("CACLAN_12", "System Cache");
|
||||
define("CACLAN_13", "Content cache contains page rendered content. This includes any content (html) that you see rendered on your site.");
|
||||
define("CACLAN_14", "System cache contains system config information. This includes site pref, currently active menus, etc. No actual content will be contained here.");
|
||||
define("CACLAN_15", "System Cache Emptied");
|
||||
define("CACLAN_16", "Empty System Cache");
|
||||
define("CACLAN_17", "Currently contains");
|
||||
define("CACLAN_18", "file");
|
||||
define("CACLAN_19", "files");
|
||||
|
||||
|
||||
?>
|
Reference in New Issue
Block a user