mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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:
parent
f804ea4abb
commit
734527370d
3 changed files with 15 additions and 7 deletions
|
@ -38,6 +38,7 @@ render-comment-cmd = /usr/local/bin/aurweb-rendercomment
|
||||||
localedir = /srv/http/aurweb/aur.git/web/locale/
|
localedir = /srv/http/aurweb/aur.git/web/locale/
|
||||||
# memcache or apc
|
# memcache or apc
|
||||||
cache = none
|
cache = none
|
||||||
|
cache_pkginfo_ttl = 86400
|
||||||
memcache_servers = 127.0.0.1:11211
|
memcache_servers = 127.0.0.1:11211
|
||||||
|
|
||||||
[ratelimit]
|
[ratelimit]
|
||||||
|
|
|
@ -292,7 +292,8 @@ class AurJSON {
|
||||||
"FROM Licenses INNER JOIN PackageLicenses " .
|
"FROM Licenses INNER JOIN PackageLicenses " .
|
||||||
"ON PackageLicenses.PackageID = " . $pkgid . " " .
|
"ON PackageLicenses.PackageID = " . $pkgid . " " .
|
||||||
"AND PackageLicenses.LicenseID = Licenses.ID";
|
"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(
|
$type_map = array(
|
||||||
'depends' => 'Depends',
|
'depends' => 'Depends',
|
||||||
|
@ -315,7 +316,8 @@ class AurJSON {
|
||||||
$query = "SELECT Keyword FROM PackageKeywords " .
|
$query = "SELECT Keyword FROM PackageKeywords " .
|
||||||
"WHERE PackageBaseID = " . intval($base_id) . " " .
|
"WHERE PackageBaseID = " . intval($base_id) . " " .
|
||||||
"ORDER BY Keyword ASC";
|
"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);
|
$data['Keywords'] = array_map(function ($x) { return $x[0]; }, $rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,8 @@ function pkg_licenses($pkgid) {
|
||||||
$q = "SELECT l.Name FROM Licenses l ";
|
$q = "SELECT l.Name FROM Licenses l ";
|
||||||
$q.= "INNER JOIN PackageLicenses pl ON pl.LicenseID = l.ID ";
|
$q.= "INNER JOIN PackageLicenses pl ON pl.LicenseID = l.ID ";
|
||||||
$q.= "WHERE pl.PackageID = ". $pkgid;
|
$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);
|
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 = "SELECT g.Name FROM `Groups` g ";
|
||||||
$q.= "INNER JOIN PackageGroups pg ON pg.GroupID = g.ID ";
|
$q.= "INNER JOIN PackageGroups pg ON pg.GroupID = g.ID ";
|
||||||
$q.= "WHERE pg.PackageID = ". $pkgid;
|
$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);
|
return array_map(function ($x) { return $x[0]; }, $rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +210,8 @@ function pkg_providers($name) {
|
||||||
$q.= "UNION ";
|
$q.= "UNION ";
|
||||||
$q.= "SELECT 0, Name FROM OfficialProviders ";
|
$q.= "SELECT 0, Name FROM OfficialProviders ";
|
||||||
$q.= "WHERE Provides = " . $dbh->quote($name);
|
$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.= "LEFT JOIN DependencyTypes dt ON dt.ID = pd.DepTypeID ";
|
||||||
$q.= "WHERE pd.PackageID = ". $pkgid . " ";
|
$q.= "WHERE pd.PackageID = ". $pkgid . " ";
|
||||||
$q.= "ORDER BY pd.DepName LIMIT " . intval($limit);
|
$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.= "LEFT JOIN RelationTypes rt ON rt.ID = pr.RelTypeID ";
|
||||||
$q.= "WHERE pr.PackageID = ". $pkgid . " ";
|
$q.= "WHERE pr.PackageID = ". $pkgid . " ";
|
||||||
$q.= "ORDER BY pr.RelName";
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue