mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Cache package provider and dependency information
The package provider and dependency queries are quite CPU-intensive and usually yield rather small result sets. Cache these values if the global caching mechanism is enabled. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
ef8bad5bbf
commit
1283fe4918
2 changed files with 28 additions and 29 deletions
|
@ -79,4 +79,21 @@ function db_cache_value($dbq, $key, $ttl=600) {
|
|||
return $value;
|
||||
}
|
||||
|
||||
# Run a simple db query, retrieving and/or caching the result set if APC is
|
||||
# available for use. Accepts an optional TTL value (defaults to 600 seconds).
|
||||
function db_cache_result($dbq, $key, $fetch_style=PDO::FETCH_NUM, $ttl=600) {
|
||||
$dbh = DB::connect();
|
||||
$status = false;
|
||||
$value = get_cache_value($key, $status);
|
||||
if (!$status) {
|
||||
$result = $dbh->query($dbq);
|
||||
if (!$result) {
|
||||
return false;
|
||||
}
|
||||
$value = $result->fetchAll($fetch_style);
|
||||
set_cache_value($key, $value, $ttl);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue