summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2019-10-07 18:19:20 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2019-10-07 18:21:03 +0200
commit734527370d1074edc2d9eadf191a6bc28fcd3dc2 (patch)
treee4a71fef80ff6928282fcd2439e3dace96726368 /web/lib/pkgfuncs.inc.php
parentf804ea4abb8001ddcc2cbc5bbb59d5f85c68b737 (diff)
downloadaur-734527370d1074edc2d9eadf191a6bc28fcd3dc2.tar.gz
aur-734527370d1074edc2d9eadf191a6bc28fcd3dc2.tar.xz
Make package details cache TTL configurable
The TTL for package details can be much longer than for generic values since they never change. Note that when an update is pushed via Git, all packages belonging to that package base are deleted and new packages are created. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index be4bb065..b5035dfc 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -165,7 +165,8 @@ function pkg_licenses($pkgid) {
$q = "SELECT l.Name FROM Licenses l ";
$q.= "INNER JOIN PackageLicenses pl ON pl.LicenseID = l.ID ";
$q.= "WHERE pl.PackageID = ". $pkgid;
- $rows = db_cache_result($q, 'licenses:' . $pkgid);
+ $ttl = config_get_int('options', 'cache_pkginfo_ttl');
+ $rows = db_cache_result($q, 'licenses:' . $pkgid, PDO::FETCH_NUM, $ttl);
return array_map(function ($x) { return $x[0]; }, $rows);
}
@@ -184,7 +185,8 @@ function pkg_groups($pkgid) {
$q = "SELECT g.Name FROM `Groups` g ";
$q.= "INNER JOIN PackageGroups pg ON pg.GroupID = g.ID ";
$q.= "WHERE pg.PackageID = ". $pkgid;
- $rows = db_cache_result($q, 'groups:' . $pkgid);
+ $ttl = config_get_int('options', 'cache_pkginfo_ttl');
+ $rows = db_cache_result($q, 'groups:' . $pkgid, PDO::FETCH_NUM, $ttl);
return array_map(function ($x) { return $x[0]; }, $rows);
}
@@ -208,7 +210,8 @@ function pkg_providers($name) {
$q.= "UNION ";
$q.= "SELECT 0, Name FROM OfficialProviders ";
$q.= "WHERE Provides = " . $dbh->quote($name);
- return db_cache_result($q, 'providers:' . $name);
+ $ttl = config_get_int('options', 'cache_pkginfo_ttl');
+ return db_cache_result($q, 'providers:' . $name, PDO::FETCH_NUM, $ttl);
}
/**
@@ -231,7 +234,8 @@ function pkg_dependencies($pkgid, $limit) {
$q.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
$q.= "WHERE pd.PackageID = ". $pkgid . " ";
$q.= "ORDER BY pd.DepName LIMIT " . intval($limit);
- return db_cache_result($q, 'dependencies:' . $pkgid);
+ $ttl = config_get_int('options', 'cache_pkginfo_ttl');
+ return db_cache_result($q, 'dependencies:' . $pkgid, PDO::FETCH_NUM, $ttl);
}
/**
@@ -251,7 +255,8 @@ function pkg_relations($pkgid) {
$q.= "LEFT JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
$q.= "WHERE pr.PackageID = ". $pkgid . " ";
$q.= "ORDER BY pr.RelName";
- return db_cache_result($q, 'relations:' . $pkgid);
+ $ttl = config_get_int('options', 'cache_pkginfo_ttl');
+ return db_cache_result($q, 'relations:' . $pkgid, PDO::FETCH_NUM, $ttl);
}
/**