summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2019-10-09 21:13:15 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2019-10-09 21:13:15 +0200
commit3ec0f6bfbf354e8d286955843bdf2d7335c9812e (patch)
tree4ba35f51c414948e4f8bc7c185821f8157a966d0 /web
parent734527370d1074edc2d9eadf191a6bc28fcd3dc2 (diff)
downloadaur-3ec0f6bfbf354e8d286955843bdf2d7335c9812e.tar.gz
aur-3ec0f6bfbf354e8d286955843bdf2d7335c9812e.tar.xz
Cache package requirements and sources
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web')
-rw-r--r--web/lib/pkgfuncs.inc.php28
1 files changed, 9 insertions, 19 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index b5035dfc..a4cd17ac 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -485,11 +485,8 @@ function pkg_required($name="", $provides, $limit) {
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
$q.= "WHERE pd.DepName IN (" . $name_list . ") ";
$q.= "ORDER BY p.Name LIMIT " . intval($limit);
- $result = $dbh->query($q);
- if (!$result) {return array();}
- while ($row = $result->fetch(PDO::FETCH_NUM)) {
- $deps[] = $row;
- }
+ /* Not invalidated by package updates. */
+ return db_cache_result($q, 'required:' . $name, PDO::FETCH_NUM);
}
return $deps;
}
@@ -502,22 +499,15 @@ function pkg_required($name="", $provides, $limit) {
* @return array All sources associated with a specific package
*/
function pkg_sources($pkgid) {
- $sources = array();
$pkgid = intval($pkgid);
- if ($pkgid > 0) {
- $dbh = DB::connect();
- $q = "SELECT Source, SourceArch FROM PackageSources ";
- $q.= "WHERE PackageID = " . $pkgid;
- $q.= " ORDER BY Source";
- $result = $dbh->query($q);
- if (!$result) {
- return array();
- }
- while ($row = $result->fetch(PDO::FETCH_NUM)) {
- $sources[] = $row;
- }
+ if (!$pkgid) {
+ return array();
}
- return $sources;
+ $q = "SELECT Source, SourceArch FROM PackageSources ";
+ $q.= "WHERE PackageID = " . $pkgid;
+ $q.= " ORDER BY Source";
+ $ttl = config_get_int('options', 'cache_pkginfo_ttl');
+ return db_cache_result($q, 'required:' . $pkgid, PDO::FETCH_NUM, $ttl);
}
/**