Index: branches/5.2.x/core/kernel/managers/cache_manager.php =================================================================== diff -u -N -r15073 -r15095 --- branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 15073) +++ branches/5.2.x/core/kernel/managers/cache_manager.php (.../cache_manager.php) (revision 15095) @@ -1,6 +1,6 @@ _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'); + $cached_data = $this->_getDBCache(Array ($name, $name . '_rebuilding', $name . '_rebuild')); + if ( $cached_data[$name . '_rebuild'] ) { + // cache rebuild requested -> rebuild now + $this->deleteDBCache($name . '_rebuild'); + + return false; + } + + $cache = $cached_data[$name]; + $rebuilding = $cached_data[$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; @@ -620,36 +622,45 @@ /** * Returns value from database cache * - * @param string $name key name + * @param string|Array $names key name * @return mixed * @access protected */ - protected function _getDBCache($name) + protected function _getDBCache($names) { + $res = Array (); + $names = (array)$names; $this->Conn->nextQueryCachable = true; - $sql = 'SELECT Data, Cached, LifeTime + $sql = 'SELECT Data, Cached, LifeTime, VarName FROM ' . TABLE_PREFIX . 'SystemCache - WHERE VarName = ' . $this->Conn->qstr($name); - $data = $this->Conn->GetRow($sql); + WHERE VarName IN (' . implode(',', $this->Conn->qstrArray($names)) . ')'; + $cached_data = $this->Conn->Query($sql, 'VarName'); - if ($data) { - $lifetime = (int)$data['LifeTime']; // in seconds - if (($lifetime > 0) && ($data['Cached'] + $lifetime < adodb_mktime())) { + foreach ($names as $name) { + if ( !isset($cached_data[$name]) ) { + $res[$name] = false; + continue; + } + + $lifetime = (int)$cached_data[$name]['LifeTime']; // in seconds + + if ( ($lifetime > 0) && ($cached_data[$name]['Cached'] + $lifetime < adodb_mktime()) ) { // delete expired $this->Conn->nextQueryCachable = true; $sql = 'DELETE FROM ' . TABLE_PREFIX . 'SystemCache WHERE VarName = ' . $this->Conn->qstr($name); $this->Conn->Query($sql); - return false; + $res[$name] = false; + continue; } - return $data['Data']; + $res[$name] = $cached_data[$name]['Data']; } - return false; + return count($res) == 1 ? array_pop($res) : $res; } /**