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>
This commit is contained in:
Lukas Fleischer 2019-10-07 12:19:20 -04:00
parent f804ea4abb
commit 734527370d
3 changed files with 15 additions and 7 deletions

View file

@ -292,7 +292,8 @@ class AurJSON {
"FROM Licenses INNER JOIN PackageLicenses " .
"ON PackageLicenses.PackageID = " . $pkgid . " " .
"AND PackageLicenses.LicenseID = Licenses.ID";
$rows = db_cache_result($query, 'extended-fields:' . $pkgid, PDO::FETCH_ASSOC);
$ttl = config_get_int('options', 'cache_pkginfo_ttl');
$rows = db_cache_result($query, 'extended-fields:' . $pkgid, PDO::FETCH_ASSOC, $ttl);
$type_map = array(
'depends' => 'Depends',
@ -315,7 +316,8 @@ class AurJSON {
$query = "SELECT Keyword FROM PackageKeywords " .
"WHERE PackageBaseID = " . intval($base_id) . " " .
"ORDER BY Keyword ASC";
$rows = db_cache_result($query, 'keywords:' . intval($base_id));
$ttl = config_get_int('options', 'cache_pkginfo_ttl');
$rows = db_cache_result($query, 'keywords:' . intval($base_id), PDO::FETCH_NUM, $ttl);
$data['Keywords'] = array_map(function ($x) { return $x[0]; }, $rows);
}