diff --git a/classes/cache.class.php b/classes/cache.class.php index 77da0f5a..5f759f14 100644 --- a/classes/cache.class.php +++ b/classes/cache.class.php @@ -83,7 +83,7 @@ public function cache_value($Key, $Value, $Duration = 2592000) { if (!$this->set($Key, $Value, 0, $Duration)) { trigger_error("Cache insert failed for key $Key"); } - if (array_key_exists($Key, $this->CacheHits)) { + if ($this->InternalCache && array_key_exists($Key, $this->CacheHits)) { $this->CacheHits[$Key] = $Value; } $this->Time += (microtime(true) - $StartTime) * 1000; @@ -100,7 +100,7 @@ public function add_value($Key, $Value, $Duration = 2592000) { public function replace_value($Key, $Value, $Duration = 2592000) { $StartTime = microtime(true); $this->replace($Key, $Value, false, $Duration); - if (array_key_exists($Key, $this->CacheHits)) { + if ($this->InternalCache && array_key_exists($Key, $this->CacheHits)) { $this->CacheHits[$Key] = $Value; } $this->Time += (microtime(true) - $StartTime) * 1000; diff --git a/gazelle.sql b/gazelle.sql index 03573e9c..119ef055 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -828,6 +828,7 @@ CREATE TABLE `sphinx_delta` ( `FileList` mediumtext, `Description` text, `VoteScore` float NOT NULL DEFAULT '0', + `LastChanged` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`ID`), KEY `GroupID` (`GroupID`) ) ENGINE=MyISAM CHARSET utf8; diff --git a/sections/ajax/better/single.php b/sections/ajax/better/single.php index 32a184ad..c828e949 100644 --- a/sections/ajax/better/single.php +++ b/sections/ajax/better/single.php @@ -1,31 +1,30 @@ -if (($GroupIDs = $Cache->get_value('better_single_groupids')) === false) { +if (($Results = $Cache->get_value('better_single_groupids')) === false) { $DB->query(" SELECT t.ID AS TorrentID, t.GroupID AS GroupID FROM xbt_files_users AS x - JOIN torrents AS t ON t.ID = x.fid - WHERE t.Format = 'FLAC' + JOIN torrents AS t ON t.ID=x.fid + WHERE t.Format='FLAC' GROUP BY x.fid HAVING COUNT(x.uid) = 1 ORDER BY t.LogScore DESC, t.Time ASC LIMIT 30"); - $GroupIDs = $DB->to_array('GroupID'); - $Cache->cache_value('better_single_groupids', $GroupIDs, 30 * 60); + $Results = $DB->to_pair('GroupID', 'TorrentID', false); + $Cache->cache_value('better_single_groupids', $Results, 30 * 60); } -$Results = Torrents::get_groups(array_keys($GroupIDs)); +$Groups = Torrents::get_groups(array_keys($Results)); $JsonResults = array(); -foreach ($GroupIDs as $GroupID) { - if (!isset($Results[$GroupID])) { +foreach ($Results as $GroupID => $FlacID) { + if (!isset($Groups[$GroupID])) { continue; } - $Group = $Results[$GroupIDs]; + $Group = $Groups[$GroupID]; extract(Torrents::array_group($Group)); - $FlacID = $GroupIDs[$GroupID]['TorrentID']; $JsonArtists = array(); if (count($Artists) > 0) { diff --git a/sections/better/single.php b/sections/better/single.php index 12425caa..fa95e06b 100644 --- a/sections/better/single.php +++ b/sections/better/single.php @@ -1,10 +1,10 @@ -if (($GroupIDs = $Cache->get_value('better_single_groupids')) === false) { +if (($Results = $Cache->get_value('better_single_groupids')) === false) { $DB->query(" SELECT t.ID AS TorrentID, t.GroupID AS GroupID - FROM xbt_files_users AS x + FROM xbt_files_users AS x JOIN torrents AS t ON t.ID=x.fid WHERE t.Format='FLAC' GROUP BY x.fid @@ -12,11 +12,11 @@ ORDER BY t.LogScore DESC, t.Time ASC LIMIT 30"); - $GroupIDs = $DB->to_array('GroupID'); - $Cache->cache_value('better_single_groupids', $GroupIDs, 30 * 60); + $Results = $DB->to_pair('GroupID', 'TorrentID', false); + $Cache->cache_value('better_single_groupids', $Results, 30 * 60); } -$Results = Torrents::get_groups(array_keys($GroupIDs)); +$Groups = Torrents::get_groups(array_keys($Results)); View::show_header('Single seeder FLACs'); ?> @@ -29,11 +29,11 @@