Attached Files |
server_load_raise_on_cache_rebuild_core_520.patch [^] (31,771 bytes) 2011-09-19 15:58
[Show Content]
Index: kernel/application.php
===================================================================
--- kernel/application.php (revision 14544)
+++ kernel/application.php (working copy)
@@ -774,12 +774,13 @@
*
* @param int $key key name from cache
* @param bool $store_locally store data locally after retrieved
+ * @param int $max_rebuild_seconds
* @return mixed
* @access public
*/
- public function getCache($key, $store_locally = true)
+ public function getCache($key, $store_locally = true, $max_rebuild_seconds = 0)
{
- return $this->cacheManager->getCache($key, $store_locally);
+ return $this->cacheManager->getCache($key, $store_locally, $max_rebuild_seconds);
}
/**
@@ -796,6 +797,18 @@
}
/**
+ * Sets rebuilding mode for given cache
+ *
+ * @param string $name
+ * @param int $mode
+ * @param int $max_rebuilding_time
+ */
+ public function rebuildCache($name, $mode = null, $max_rebuilding_time = 0)
+ {
+ $this->cacheManager->rebuildCache($name, $mode, $max_rebuilding_time);
+ }
+
+ /**
* Deletes key from cache
*
* @param string $key
@@ -820,12 +833,13 @@
* Returns value from database cache
*
* @param string $name key name
+ * @param int $max_rebuild_seconds
* @return mixed
* @access public
*/
- public function getDBCache($name)
+ public function getDBCache($name, $max_rebuild_seconds = 0)
{
- return $this->cacheManager->getDBCache($name);
+ return $this->cacheManager->getDBCache($name, $max_rebuild_seconds);
}
/**
@@ -833,7 +847,7 @@
*
* @param string $name
* @param mixed $value
- * @param int $expiration
+ * @param int|bool $expiration
* @access public
*/
public function setDBCache($name, $value, $expiration = false)
@@ -842,6 +856,18 @@
}
/**
+ * Sets rebuilding mode for given cache
+ *
+ * @param string $name
+ * @param int $mode
+ * @param int $max_rebuilding_time
+ */
+ public function rebuildDBCache($name, $mode = null, $max_rebuilding_time = 0)
+ {
+ $this->cacheManager->rebuildDBCache($name, $mode, $max_rebuilding_time);
+ }
+
+ /**
* Deletes key from database cache
*
* @param string $name
Index: kernel/managers/cache_manager.php
===================================================================
--- kernel/managers/cache_manager.php (revision 14544)
+++ kernel/managers/cache_manager.php (working copy)
@@ -201,14 +201,14 @@
*/
public function LoadUnitCache()
{
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $data = $this->Application->getCache('master:configs_parsed', false);
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $data = $this->Application->getCache('master:configs_parsed', false, CacheSettings::$unitCacheRebuildTime);
}
else {
- $data = $this->Application->getDBCache('configs_parsed');
+ $data = $this->Application->getDBCache('configs_parsed', CacheSettings::$unitCacheRebuildTime);
}
- if ($data) {
+ if ( $data ) {
$cache = unserialize($data); // 126 KB all modules
unset($data);
@@ -230,6 +230,13 @@
}
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:configs_parsed', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('configs_parsed', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
+ }
+
return false;
}
@@ -326,18 +333,18 @@
public function DeleteUnitCache($include_sections = false)
{
if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:configs_parsed');
+ $this->Application->rebuildCache('master:configs_parsed', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
else {
- $this->Application->deleteDBCache('configs_parsed');
+ $this->Application->rebuildDBCache('configs_parsed', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
if ($include_sections) {
if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:sections_parsed');
+ $this->Application->rebuildCache('master:sections_parsed', kCache::REBUILD_LATER, CacheSettings::$sectionsParsedRebuildTime);
}
else {
- $this->Application->deleteDBCache('sections_parsed');
+ $this->Application->rebuildDBCache('sections_parsed', kCache::REBUILD_LATER, CacheSettings::$sectionsParsedRebuildTime);
}
}
}
@@ -447,12 +454,13 @@
*
* @param int $key key name from cache
* @param bool $store_locally store data locally after retrieved
+ * @param int $max_rebuild_seconds
* @return mixed
* @access public
*/
- public function getCache($key, $store_locally = true)
+ public function getCache($key, $store_locally = true, $max_rebuild_seconds = 0)
{
- return $this->cacheHandler->getCache($key, $store_locally);
+ return $this->cacheHandler->getCache($key, $store_locally, $max_rebuild_seconds);
}
/**
@@ -469,6 +477,18 @@
}
/**
+ * Sets rebuilding mode for given cache
+ *
+ * @param string $name
+ * @param int $mode
+ * @param int $max_rebuilding_time
+ */
+ public function rebuildCache($name, $mode = null, $max_rebuilding_time = 0)
+ {
+ $this->cacheHandler->rebuildCache($name, $mode, $max_rebuilding_time);
+ }
+
+ /**
* Deletes key from cache
*
* @param string $key
@@ -493,11 +513,51 @@
* Returns value from database cache
*
* @param string $name key name
+ * @param int $max_rebuild_seconds
* @return mixed
* @access public
*/
- public function getDBCache($name)
+ public function getDBCache($name, $max_rebuild_seconds = 0)
{
+ if ( $this->_getDBCache($name . '_rebuild') ) {
+ // cache rebuild requested -> rebuild now
+ $this->deleteDBCache($name . '_rebuild');
+
+ return false;
+ }
+
+ // no serials in cache key OR cache is outdated
+ $wait_seconds = $max_rebuild_seconds;
+
+ while (true) {
+ $cache = $this->_getDBCache($name);
+ $rebuilding = $this->_getDBCache($name . '_rebuilding');
+
+ if ( ($cache === false) && (!$rebuilding || $wait_seconds == 0) ) {
+ // cache missing and nobody rebuilding it -> rebuild; enough waiting for cache to be ready
+ return false;
+ }
+ elseif ( $cache !== false ) {
+ // cache present -> return it
+ return $cache;
+ }
+
+ $wait_seconds -= kCache::WAIT_STEP;
+ sleep(kCache::WAIT_STEP);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns value from database cache
+ *
+ * @param string $name key name
+ * @return mixed
+ * @access protected
+ */
+ protected function _getDBCache($name)
+ {
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT Data, Cached, LifeTime
@@ -529,11 +589,25 @@
*
* @param string $name
* @param mixed $value
- * @param int $expiration
+ * @param int|bool $expiration
* @access public
*/
public function setDBCache($name, $value, $expiration = false)
{
+ $this->deleteDBCache($name . '_rebuilding');
+ $this->_setDBCache($name, $value, $expiration);
+ }
+
+ /**
+ * Sets value to database cache
+ *
+ * @param string $name
+ * @param mixed $value
+ * @param int|bool $expiration
+ * @access protected
+ */
+ protected function _setDBCache($name, $value, $expiration = false)
+ {
if ((int)$expiration <= 0) {
$expiration = -1;
}
@@ -550,6 +624,25 @@
}
/**
+ * Sets rebuilding mode for given cache
+ *
+ * @param string $name
+ * @param int $mode
+ * @param int $max_rebuilding_time
+ */
+ public function rebuildDBCache($name, $mode = null, $max_rebuilding_time = 0)
+ {
+ if ( !isset($mode) || $mode == kCache::REBUILD_NOW ) {
+ $this->_setDBCache($name . '_rebuilding', 1, $max_rebuilding_time);
+ $this->deleteDBCache($name . '_rebuild');
+ }
+ elseif ( $mode == kCache::REBUILD_LATER ) {
+ $this->_setDBCache($name . '_rebuild', 1, 0);
+ $this->deleteDBCache($name . '_rebuilding');
+ }
+ }
+
+ /**
* Deletes key from database cache
*
* @param string $name
Index: kernel/startup.php
===================================================================
--- kernel/startup.php (revision 14544)
+++ kernel/startup.php (working copy)
@@ -64,6 +64,14 @@
define('PORT', $_SERVER['HTTP_PORT']);
}
+ if (!$vars) {
+ echo 'In-Portal is probably not installed, or configuration file is missing.<br/>';
+ echo 'Please use the installation script to fix the problem.<br/><br/>';
+ echo '<a href="' . PROTOCOL . SERVER_NAME . rtrim(BASE_PATH, '/') . '/core/install.php">Go to installation script</a><br><br>';
+ flush();
+ exit;
+ }
+
define('APPLICATION_CLASS', isset($vars['ApplicationClass']) ? $vars['ApplicationClass'] : 'kApplication');
define('APPLICATION_PATH', isset($vars['ApplicationPath']) ? $vars['ApplicationPath'] : '/core/kernel/application.php');
@@ -72,14 +80,6 @@
define('WRITEBALE_BASE', $vars['WriteablePath']);
}
- if (!$vars) {
- echo 'In-Portal is probably not installed, or configuration file is missing.<br/>';
- echo 'Please use the installation script to fix the problem.<br/><br/>';
- echo '<a href="' . PROTOCOL . SERVER_NAME . rtrim(BASE_PATH, '/') . '/core/install.php">Go to installation script</a><br><br>';
- flush();
- exit;
- }
-
define('SQL_TYPE', $vars['DBType']);
define('SQL_SERVER', $vars['DBHost']);
define('SQL_USER', $vars['DBUser']);
@@ -117,6 +117,22 @@
define('CACHING_TYPE_MEMORY', 1);
define('CACHING_TYPE_TEMPORARY', 2);
+ class CacheSettings {
+ static public $unitCacheRebuildTime;
+ static public $structureTreeRebuildTime;
+ static public $cmsMenuRebuildTime;
+ static public $templateMappingRebuildTime;
+ static public $sectionsParsedRebuildTime;
+ static public $domainsParsedRebuildTime;
+ }
+
+ CacheSettings::$unitCacheRebuildTime = isset($vars['UnitCacheRebuildTime']) ? $vars['UnitCacheRebuildTime'] : 10;
+ CacheSettings::$structureTreeRebuildTime = isset($vars['StructureTreeRebuildTime']) ? $vars['StructureTreeRebuildTime'] : 10;
+ CacheSettings::$cmsMenuRebuildTime = isset($vars['CmsMenuRebuildTime']) ? $vars['CmsMenuRebuildTime'] : 10;
+ CacheSettings::$templateMappingRebuildTime = isset($vars['TemplateMappingRebuildTime']) ? $vars['TemplateMappingRebuildTime'] : 5;
+ CacheSettings::$sectionsParsedRebuildTime = isset($vars['SectionsParsedRebuildTime']) ? $vars['SectionsParsedRebuildTime'] : 10;
+ CacheSettings::$domainsParsedRebuildTime = isset($vars['DomainsParsedRebuildTime']) ? $vars['DomainsParsedRebuildTime'] : 2;
+
unset($vars); // just in case someone will be still using it
if (ini_get('safe_mode')) {
Index: kernel/utility/cache.php
===================================================================
--- kernel/utility/cache.php (revision 14544)
+++ kernel/utility/cache.php (working copy)
@@ -21,6 +21,24 @@
class kCache extends kBase {
/**
+ * Rebuild cache now
+ *
+ */
+ const REBUILD_NOW = 1;
+
+ /**
+ * Rebuild cache later
+ *
+ */
+ const REBUILD_LATER = 2;
+
+ /**
+ * Cache waiting step (in seconds)
+ *
+ */
+ const WAIT_STEP = 2;
+
+ /**
* Object of cache handler
*
* @var FakeCacheHandler
@@ -142,27 +160,110 @@
*/
function setCache($name, $value, $expiration)
{
- $name = $this->prepareKeyName($name);
- $this->_localStorage[$name] = $value;
+ // 1. stores current version of serial for given cache key
+ $this->_setCache($name . '_serials', $this->replaceSerials($name), $expiration);
- return $this->_handler->set($name, $value, $expiration);
+ // 2. remove rebuilding mark
+ $this->delete($name . '_rebuilding');
+
+ return $this->_setCache($name, $value, $expiration);
}
/**
+ * Stores value to cache
+ *
+ * @param string $name
+ * @param mixed $value
+ * @param int $expires cache record expiration time in seconds
+ */
+ function _setCache($name, $value, $expiration)
+ {
+ $prepared_name = $this->prepareKeyName($name);
+ $this->_localStorage[$prepared_name] = $value;
+
+ return $this->_handler->set($prepared_name, $value, $expiration);
+ }
+
+ /**
+ * Sets rebuilding mode for given cache
+ *
+ * @param string $name
+ * @param int $mode
+ * @param int $max_rebuilding_time
+ */
+ function rebuildCache($name, $mode = null, $max_rebuilding_time = 0)
+ {
+ if ( !isset($mode) || $mode == self::REBUILD_NOW ) {
+ $this->_setCache($name . '_rebuilding', 1, $max_rebuilding_time);
+ $this->delete($name . '_rebuild');
+ }
+ elseif ( $mode == self::REBUILD_LATER ) {
+ $this->_setCache($name . '_rebuild', 1, 0);
+ $this->delete($name . '_rebuilding');
+ }
+ }
+
+ /**
* Returns value from cache
*
* @param string $name
* @param bool $store_locally store data locally after retrieved
- * @param bool $replace_serials
+ * @param int $max_rebuild_seconds
* @return mixed
*/
- function getCache($name, $store_locally = true, $replace_serials = true)
+ function getCache($name, $store_locally = true, $max_rebuild_seconds = 0)
{
- $name = $this->prepareKeyName($name, $replace_serials);
+ if ( $this->_getCache($name . '_rebuild') ) {
+ // cache rebuild requested -> rebuild now
+ $this->delete($name . '_rebuild');
+ return false;
+ }
+
+ $new_serial = $this->replaceSerials($name);
+ $old_serial = $this->_getCache($name . '_serials');
+
+ if ( $name == $new_serial || $new_serial != $old_serial ) {
+ // no serials in cache key OR cache is outdated
+ $wait_seconds = $max_rebuild_seconds;
+
+ while (true) {
+ $cache = $this->_getCache($name, $store_locally);
+ $rebuilding = $this->_getCache($name . '_rebuilding', false);
+
+ if ( ($cache === false) && (!$rebuilding || $wait_seconds == 0) ) {
+ // cache missing and nobody rebuilding it -> rebuild; enough waiting for cache to be ready
+ return false;
+ }
+ elseif ( $cache !== false ) {
+ // cache present (if other user is rebuilding it, then it's outdated cache) -> return it
+ return $rebuilding || $new_serial == $old_serial ? $cache : false;
+ }
+
+ $wait_seconds -= self::WAIT_STEP;
+ sleep(self::WAIT_STEP);
+ }
+
+ return $cache;
+ }
+
+ return $this->_getCache($name, $store_locally);
+ }
+
+ /**
+ * Returns value from cache
+ *
+ * @param string $name
+ * @param bool $store_locally store data locally after retrieved
+ * @return mixed
+ */
+ function _getCache($name, $store_locally = true)
+ {
+ $name = $this->prepareKeyName($name);
+
if ($store_locally) {
- if (array_key_exists($name, $this->_localStorage)) {
- if ($this->displayCacheStatistics) {
+ if ( array_key_exists($name, $this->_localStorage) ) {
+ if ( $this->displayCacheStatistics ) {
$this->setStatistics($name, $this->_localStorage[$name]);
}
@@ -172,7 +273,7 @@
$res = $this->_handler->get($name);
- if ($replace_serials && $this->debugCache) {
+ if ($this->debugCache) {
// don't display subsequent serial cache retrievals (ones, that are part of keys)
if (is_array($res)) {
$this->Application->Debugger->appendHTML('Restoring key "' . $name . '". Type: ' . gettype($res) . '.');
@@ -188,10 +289,10 @@
}
}
- if ($store_locally && ($res !== false)) {
+ if ( $store_locally && ($res !== false) ) {
$this->_localStorage[$name] = $res;
- if ($this->displayCacheStatistics) {
+ if ( $this->displayCacheStatistics ) {
$this->setStatistics($name, $res);
}
}
@@ -232,27 +333,37 @@
* Replaces serials and adds unique site prefix to cache variable name
*
* @param string $name
- * @param bool $replace_serials
* @return string
*/
- function prepareKeyName($name, $replace_serials = true)
+ protected function prepareKeyName($name)
{
- // replace serials in key name
- if ($replace_serials && preg_match_all('/\[%(.*?)%\]/', $name, $regs)) {
+ if ( $this->cachingType == CACHING_TYPE_TEMPORARY ) {
+ return $name;
+ }
+
+ // add site-wide prefix to key
+ return $this->_cachePrefix() . $name;
+ }
+
+ /**
+ * Replaces serials within given string
+ *
+ * @param string $value
+ * @return string
+ * @access protected
+ */
+ protected function replaceSerials($value)
+ {
+ if ( preg_match_all('/\[%(.*?)%\]/', $value, $regs) ) {
// [%LangSerial%] - prefix-wide serial in case of any change in "lang" prefix
// [%LangIDSerial:5%] - one id-wide serial in case of data, associated with given id was changed
// [%CiIDSerial:ItemResourceId:5%] - foreign key-based serial in case of data, associated with given foreign key was changed
foreach ($regs[1] as $serial_name) {
- $name = str_replace('[%' . $serial_name . '%]', '[' . $serial_name . '=' . $this->getCache($serial_name, true, false) . ']', $name);
+ $value = str_replace('[%' . $serial_name . '%]', '[' . $serial_name . '=' . $this->_getCache($serial_name, true) . ']', $value);
}
}
- if ($this->cachingType == CACHING_TYPE_TEMPORARY) {
- return $name;
- }
-
- // add site-wide prefix to key
- return $this->_cachePrefix() . $name;
+ return $value;
}
/**
Index: kernel/utility/unit_config_reader.php
===================================================================
--- kernel/utility/unit_config_reader.php (revision 14544)
+++ kernel/utility/unit_config_reader.php (working copy)
@@ -178,14 +178,14 @@
{
$this->Application->refreshModuleInfo();
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $data = $this->Application->getCache('master:config_files', false);
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $data = $this->Application->getCache('master:config_files', false, CacheSettings::$unitCacheRebuildTime);
}
else {
- $data = $this->Application->getDBCache('config_files');
+ $data = $this->Application->getDBCache('config_files', CacheSettings::$unitCacheRebuildTime);
}
- if ($data) {
+ if ( $data ) {
$this->configFiles = unserialize($data);
if ( !defined('DBG_VALIDATE_CONFIGS') && !DBG_VALIDATE_CONFIGS ) {
@@ -193,6 +193,13 @@
}
}
else {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:config_files', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('config_files', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
+ }
+
$this->findConfigFiles(FULL_PATH . DIRECTORY_SEPARATOR . 'core'); // search from core directory
$this->findConfigFiles($folderPath); // search from modules directory
Index: units/admin/admin_events_handler.php
===================================================================
--- units/admin/admin_events_handler.php (revision 14544)
+++ units/admin/admin_events_handler.php (working copy)
@@ -105,10 +105,10 @@
}
if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:sections_parsed');
+ $this->Application->rebuildCache('master:sections_parsed', kCache::REBUILD_LATER, CacheSettings::$sectionsParsedRebuildTime);
}
else {
- $this->Application->deleteDBCache('sections_parsed');
+ $this->Application->rebuildDBCache('sections_parsed', kCache::REBUILD_LATER, CacheSettings::$sectionsParsedRebuildTime);
}
$event->SetRedirectParam('refresh_tree', 1);
@@ -121,10 +121,10 @@
}
if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:config_files');
+ $this->Application->rebuildCache('master:config_files', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
else {
- $this->Application->deleteDBCache('config_files');
+ $this->Application->rebuildDBCache('config_files', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
$this->OnResetParsedData($event);
Index: units/categories/categories_event_handler.php
===================================================================
--- units/categories/categories_event_handler.php (revision 14544)
+++ units/categories/categories_event_handler.php (working copy)
@@ -703,6 +703,8 @@
// loding anyway, because this object is needed by "c-perm:OnBeforeDeleteFromLive" event
$temp_object =& $event->getObject( Array('skip_autoload' => true) );
+ /* @var $temp_object kDBItem */
+
$temp_object->Load($id);
if ($id == 0) {
@@ -925,6 +927,7 @@
$change_events = Array ('OnPreSave', 'OnPreSaveCreated', 'OnUpdate', 'OnSave');
if ($type == 'after' && in_array($event->Name, $change_events)) {
$object =& $event->getObject();
+ /* @var $object kDBItem */
$tmp = $this->Application->RecallVar('priority_changes'.$this->Application->GetVar('m_wid'));
$changes = $tmp ? unserialize($tmp) : array();
@@ -998,8 +1001,13 @@
$to_delete = array();
if ($recycle_bin = $this->Application->ConfigValue('RecycleBinFolder')) {
$rb =& $this->Application->recallObject('c.recycle', null, Array ('skip_autoload' => true));
+ /* @var $rb CategoriesItem */
+
$rb->Load($recycle_bin);
+
$cat =& $event->getObject(Array('skip_autoload' => true));
+ /* @var $cat CategoriesItem */
+
foreach ($ids as $id) {
$cat->Load($id);
if (preg_match('/^'.preg_quote($rb->GetDBField('ParentPath'),'/').'/', $cat->GetDBField('ParentPath'))) {
@@ -1325,6 +1333,7 @@
}
$object =& $event->getObject();
+ /* @var $object kDBItem */
$cache_updater =& $this->Application->makeClass('kPermCacheUpdater', Array (null, $object->GetDBField('ParentPath')));
/* @var $cache_updater kPermCacheUpdater */
@@ -1402,6 +1411,8 @@
}
$object =& $event->getObject( Array('skip_autoload' => true) );
+ /* @var $object CategoriesItem */
+
$ids = $this->StoreSelectedIDs($event);
if ($ids) {
@@ -1652,6 +1663,7 @@
function OnBeforeItemDelete(&$event)
{
$object =& $event->getObject();
+ /* @var $object kDBItem */
if ( $object->GetDBField('Protected') && !$this->Application->isDebugMode() ) {
$event->status = kEvent::erFAIL;
@@ -1851,14 +1863,14 @@
{
// reset cms menu cache (all variables are automatically rebuild, when missing)
if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:cms_menu');
- $this->Application->deleteCache('master:StructureTree');
- $this->Application->deleteCache('master:template_mapping');
+ $this->Application->rebuildCache('master:cms_menu', kCache::REBUILD_LATER, CacheSettings::$cmsMenuRebuildTime);
+ $this->Application->rebuildCache('master:StructureTree', kCache::REBUILD_LATER, CacheSettings::$structureTreeRebuildTime);
+ $this->Application->rebuildCache('master:template_mapping', kCache::REBUILD_LATER, CacheSettings::$templateMappingRebuildTime);
}
else {
- $this->Application->deleteDBCache('cms_menu');
- $this->Application->deleteDBCache('StructureTree');
- $this->Application->deleteDBCache('template_mapping');
+ $this->Application->rebuildDBCache('cms_menu', kCache::REBUILD_LATER, CacheSettings::$cmsMenuRebuildTime);
+ $this->Application->rebuildDBCache('StructureTree', kCache::REBUILD_LATER, CacheSettings::$structureTreeRebuildTime);
+ $this->Application->rebuildDBCache('template_mapping', kCache::REBUILD_LATER, CacheSettings::$templateMappingRebuildTime);
}
}
@@ -1966,6 +1978,7 @@
}
$object =& $event->getObject();
+ /* @var $object kDBItem */
// remove this category & it's children from dropdown
$sql = 'SELECT '.$object->IDField.'
Index: units/helpers/category_helper.php
===================================================================
--- units/helpers/category_helper.php (revision 14544)
+++ units/helpers/category_helper.php (working copy)
@@ -439,11 +439,11 @@
function &_getStructureTree()
{
// get cached version of structure tree
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $data = $this->Application->getCache('master:StructureTree', false);
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $data = $this->Application->getCache('master:StructureTree', false, CacheSettings::$structureTreeRebuildTime);
}
else {
- $data = $this->Application->getDBCache('StructureTree');
+ $data = $this->Application->getDBCache('StructureTree', CacheSettings::$structureTreeRebuildTime);
}
if ($data) {
@@ -452,6 +452,13 @@
return $data;
}
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:StructureTree', kCache::REBUILD_NOW, CacheSettings::$structureTreeRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('StructureTree', kCache::REBUILD_NOW, CacheSettings::$structureTreeRebuildTime);
+ }
+
// generate structure tree from scratch
$ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
/* @var $ml_helper kMultiLanguageHelper */
@@ -472,17 +479,24 @@
function getTemplateMapping()
{
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $data = $this->Application->getCache('master:template_mapping', false);
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $data = $this->Application->getCache('master:template_mapping', false, CacheSettings::$templateMappingRebuildTime);
}
else {
- $data = $this->Application->getDBCache('template_mapping');
+ $data = $this->Application->getDBCache('template_mapping', CacheSettings::$templateMappingRebuildTime);
}
- if ($data) {
+ if ( $data ) {
return unserialize($data);
}
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:template_mapping', kCache::REBUILD_NOW, CacheSettings::$templateMappingRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('template_mapping', kCache::REBUILD_NOW, CacheSettings::$templateMappingRebuildTime);
+ }
+
$sql = 'SELECT
IF(c.`Type` = ' . PAGE_TYPE_TEMPLATE . ', CONCAT(c.Template, ":", c.ThemeId), CONCAT("id:", c.CategoryId)) AS SrcTemplate,
LOWER(
Index: units/helpers/menu_helper.php
===================================================================
--- units/helpers/menu_helper.php (revision 14544)
+++ units/helpers/menu_helper.php (working copy)
@@ -128,12 +128,12 @@
}
}
- if (!$this->Menu) {
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $menu = $this->Application->getCache('master:cms_menu', false);
+ if ( !$this->Menu ) {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $menu = $this->Application->getCache('master:cms_menu', false, CacheSettings::$cmsMenuRebuildTime);
}
else {
- $menu = $this->Application->getDBCache('cms_menu');
+ $menu = $this->Application->getDBCache('cms_menu', CacheSettings::$cmsMenuRebuildTime);
}
if ($menu) {
@@ -141,6 +141,13 @@
$this->parentPaths = $menu['parentPaths'];
}
else {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:cms_menu', kCache::REBUILD_NOW, CacheSettings::$cmsMenuRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('cms_menu', kCache::REBUILD_NOW, CacheSettings::$cmsMenuRebuildTime);
+ }
+
$menu = $this->_altBuildMenuStructure(Array ('CategoryId' => $root_cat, 'ParentPath' => $root_path));
$menu['parentPaths'] = $this->parentPaths;
Index: units/helpers/sections_helper.php
===================================================================
--- units/helpers/sections_helper.php (revision 14544)
+++ units/helpers/sections_helper.php (working copy)
@@ -70,19 +70,26 @@
*/
function BuildTree()
{
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $data = $this->Application->getCache('master:sections_parsed', false);
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $data = $this->Application->getCache('master:sections_parsed', false, CacheSettings::$sectionsParsedRebuildTime);
}
else {
- $data = $this->Application->getDBCache('sections_parsed');
+ $data = $this->Application->getDBCache('sections_parsed', CacheSettings::$sectionsParsedRebuildTime);
}
- if ($data) {
+ if ( $data ) {
$this->Tree = unserialize($data);
return ;
}
- if (!(defined('IS_INSTALL') && IS_INSTALL)) {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:sections_parsed', kCache::REBUILD_NOW, CacheSettings::$sectionsParsedRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('sections_parsed', kCache::REBUILD_NOW, CacheSettings::$sectionsParsedRebuildTime);
+ }
+
+ if ( !defined('IS_INSTALL') || !IS_INSTALL ) {
// don't reread all configs during install, because they are reread on every install step
$this->Application->UnitConfigReader->ReReadConfigs();
}
@@ -201,7 +208,7 @@
$this->Application->HandleEvent( new kEvent('adm:OnAfterBuildTree') );
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
$this->Application->setCache('master:sections_parsed', serialize($this->Tree));
}
else {
Index: units/helpers/site_helper.php
===================================================================
--- units/helpers/site_helper.php (revision 14544)
+++ units/helpers/site_helper.php (working copy)
@@ -65,18 +65,25 @@
{
static $cache = null;
- if (!isset($cache)) {
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $cache = $this->Application->getCache('master:domains_parsed', false);
+ if ( !isset($cache) ) {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $cache = $this->Application->getCache('master:domains_parsed', false, CacheSettings::$domainsParsedRebuildTime);
}
else {
- $cache = $this->Application->getDBCache('domains_parsed');
+ $cache = $this->Application->getDBCache('domains_parsed', CacheSettings::$domainsParsedRebuildTime);
}
if ($cache) {
$cache = unserialize($cache);
}
else {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:domains_parsed', kCache::REBUILD_NOW, CacheSettings::$domainsParsedRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('domains_parsed', kCache::REBUILD_NOW, CacheSettings::$domainsParsedRebuildTime);
+ }
+
$sql = 'SELECT *
FROM ' . TABLE_PREFIX . 'SiteDomains
ORDER BY Priority DESC';
Index: units/site_domains/site_domain_eh.php
===================================================================
--- units/site_domains/site_domain_eh.php (revision 14544)
+++ units/site_domains/site_domain_eh.php (working copy)
@@ -195,11 +195,11 @@
*/
function _deleteCache()
{
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:domains_parsed');
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:domains_parsed', kCache::REBUILD_LATER, CacheSettings::$domainsParsedRebuildTime);
}
else {
- $this->Application->deleteDBCache('domains_parsed');
+ $this->Application->rebuildDBCache('domains_parsed', kCache::REBUILD_LATER, CacheSettings::$domainsParsedRebuildTime);
}
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'CachedUrls';
server_load_raise_on_cache_rebuild_modules_520.patch [^] (1,589 bytes) 2011-09-19 15:58
[Show Content]
Index: in-auction/units/helpers/ebay_helper.php
===================================================================
--- in-auction/units/helpers/ebay_helper.php (revision 14544)
+++ in-auction/units/helpers/ebay_helper.php (working copy)
@@ -378,10 +378,10 @@
function ClearConfigCache()
{
if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:configs_parsed');
+ $this->Application->rebuildCache('master:configs_parsed', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
else {
- $this->Application->deleteDBCache('configs_parsed');
+ $this->Application->rebuildDBCache('configs_parsed', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
}
Index: in-auction/units/sections/ebay_eh.php
===================================================================
--- in-auction/units/sections/ebay_eh.php (revision 14544)
+++ in-auction/units/sections/ebay_eh.php (working copy)
@@ -3348,11 +3348,11 @@
function ClearConfigCache()
{
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
- $this->Application->deleteCache('master:configs_parsed');
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:configs_parsed', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
else {
- $this->Application->deleteDBCache('configs_parsed');
+ $this->Application->rebuildDBCache('configs_parsed', kCache::REBUILD_LATER, CacheSettings::$unitCacheRebuildTime);
}
}
install_step2_infinite_cache_waiting.patch [^] (2,157 bytes) 2011-09-20 12:31
[Show Content]
Index: kernel/utility/unit_config_reader.php
===================================================================
--- kernel/utility/unit_config_reader.php (revision 14573)
+++ kernel/utility/unit_config_reader.php (working copy)
@@ -17,7 +17,7 @@
class kUnitConfigReader extends kBase implements kiCacheable {
/**
- * Configs readed
+ * Configs reader
*
* @var Array
* @access private
@@ -124,7 +124,7 @@
$this->ParseConfigs();
// tell AfterConfigRead to store cache if needed
- // can't store it here beacuse AfterConfigRead needs ability to change config data
+ // can't store it here because AfterConfigRead needs ability to change config data
$this->StoreCache = $cache;
if (!$this->Application->InitDone) {
@@ -193,18 +193,20 @@
}
}
else {
- if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
- $this->Application->rebuildCache('master:config_files', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
+ if ( $cache ) {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
+ $this->Application->rebuildCache('master:config_files', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
+ }
+ else {
+ $this->Application->rebuildDBCache('config_files', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
+ }
}
- else {
- $this->Application->rebuildDBCache('config_files', kCache::REBUILD_NOW, CacheSettings::$unitCacheRebuildTime);
- }
$this->findConfigFiles(FULL_PATH . DIRECTORY_SEPARATOR . 'core'); // search from core directory
$this->findConfigFiles($folderPath); // search from modules directory
- if ($cache) {
- if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) {
+ if ( $cache ) {
+ if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
$this->Application->setCache('master:config_files', serialize($this->configFiles));
}
else {
@@ -268,7 +270,7 @@
}
if ( !isset($store_cache) ) {
- // store cache not overrided -> use global setting
+ // $store_cache not overridden -> use global setting
$store_cache = $this->StoreCache;
}
Parallel cache rebuild prevention.vsd [^] (54,784 bytes) 2011-09-25 04:48
Parallel cache rebuild prevention.png [^] (33,857 bytes) 2011-09-25 04:48
|