Index: branches/5.1.x/core/kernel/db/cat_event_handler.php =================================================================== diff -u -N -r13159 -r13168 --- branches/5.1.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 13159) +++ branches/5.1.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 13168) @@ -1,6 +1,6 @@ '.(adodb_mktime() - 3600).')'; - $hot_limit = $this->Conn->GetOne($sql); + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { + $serial_name = $this->Application->incrementCacheSerial($event->Prefix, null, false); + $hot_limit = $this->Application->getCache($property_map['HotLimit'] . '[%' . $serial_name . '%]'); + } + else { + $hot_limit = $this->Application->getDBCache($property_map['HotLimit']); + } + if ($hot_limit === false) { $hot_limit = $this->CalculateHotLimit($event); } + $object->addCalculatedField('IsHot', ' IF(%1$s.HotItem = 2, IF(%1$s.'.$property_map['ClickField'].' >= '.$hot_limit.', 1, 0), %1$s.HotItem @@ -840,9 +845,11 @@ function CalculateHotLimit(&$event) { $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); + if (!$property_map) { return; } + $click_field = $property_map['ClickField']; $last_hot = $this->Application->ConfigValue($property_map['MaxHotNumber']) - 1; @@ -851,10 +858,16 @@ LIMIT '.$last_hot.', 1'; $res = $this->Conn->GetCol($sql); $hot_limit = (double)array_shift($res); - $this->Conn->Query('REPLACE INTO '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("'.$property_map['HotLimit'].'", "'.$hot_limit.'", '.adodb_mktime().')'); - return $hot_limit; - return 0; + if ($this->Application->isCachingType(CACHING_TYPE_MEMORY)) { + $serial_name = $this->Application->incrementCacheSerial($event->Prefix, null, false); + $this->Application->setCache($property_map['HotLimit'] . '[%' . $serial_name . '%]', $hot_limit); + } + else { + $this->Application->setDBCache($property_map['HotLimit'], $hot_limit, 3600); + } + + return $hot_limit; } /** @@ -1604,10 +1617,7 @@ case 'HotItem': $hot_limit_var = getArrayValue($property_mappings, 'HotLimit'); if ($hot_limit_var) { - $sql = 'SELECT Data - FROM '.TABLE_PREFIX.'Cache - WHERE VarName = "'.$hot_limit_var.'"'; - $hot_limit = (int)$this->Conn->GetOne($sql); + $hot_limit = (int)$this->Application->getDBCache($hot_limit_var); $condition = 'IF('.$items_table.'.HotItem = 2, IF('.$items_table.'.Hits >= '.