summaryrefslogtreecommitdiffstats
path: root/web/lib/aur.inc.php
diff options
context:
space:
mode:
authorelij <elij.mx@gmail.com>2011-05-29 23:27:55 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2011-06-22 15:21:21 +0200
commit5853097561cddd1a2405ac9d9b9659ca8772cc5e (patch)
treeb7df520c01981532a5d045153ce329ca693d3206 /web/lib/aur.inc.php
parent888db089c515270fd5cd9a9bedd217110f43bc4c (diff)
downloadaur-5853097561cddd1a2405ac9d9b9659ca8772cc5e.tar.gz
aur-5853097561cddd1a2405ac9d9b9659ca8772cc5e.tar.xz
Make cache type selectable based on config value
Provie a mechanism to specify cache type from NONE, APC, or MEMCACHE based on a config variable. If MEMCACHE type is selected, a list of servers can be specified to provide multiserver support. Note that php-memcaced is required for MEMCACHE support. Lukas: Minor commenting style fixes. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib/aur.inc.php')
-rw-r--r--web/lib/aur.inc.php47
1 files changed, 1 insertions, 46 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 572d781a..4c2cc559 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -13,12 +13,7 @@ set_lang();
include_once("config.inc.php");
include_once("version.inc.php");
include_once("acctfuncs.inc.php");
-
-# Check if APC extension is loaded, and set cache prefix if it is.
-if (!defined('EXTENSION_LOADED_APC')) {
- define('EXTENSION_LOADED_APC', extension_loaded('apc'));
- define('APC_PREFIX', 'aur:');
-}
+include_once("cachefuncs.inc.php");
# see if the visitor is already logged in
#
@@ -263,46 +258,6 @@ function db_query($query="", $db_handle="") {
return $result;
}
-# Set a value in the cache (currently APC) if cache is available for use. If
-# not available, this becomes effectively a no-op (return value is
-# false). Accepts an optional TTL (defaults to 600 seconds).
-function set_cache_value($key, $value, $ttl=600) {
- $status = false;
- if (EXTENSION_LOADED_APC) {
- $status = apc_store(APC_PREFIX.$key, $value, $ttl);
- }
- return $status;
-}
-
-# Get a value from the cache (currently APC) if cache is available for use. If
-# not available, this returns false (optionally sets passed in variable $status
-# to false, much like apc_fetch() behaves). This allows for testing the fetch
-# result appropriately even in the event that a 'false' value was the value in
-# the cache.
-function get_cache_value($key, &$status=false) {
- if(EXTENSION_LOADED_APC) {
- $ret = apc_fetch(APC_PREFIX.$key, $status);
- if ($status) {
- return $ret;
- }
- }
- return $status;
-}
-
-# Run a simple db query, retrieving and/or caching the value if APC is
-# available for use. Accepts an optional TTL value (defaults to 600 seconds).
-function db_cache_value($dbq, $dbh, $key, $ttl=600) {
- $status = false;
- $value = get_cache_value($key, $status);
- if (!$status) {
- $result = db_query($dbq, $dbh);
- $row = mysql_fetch_row($result);
- $value = $row[0];
- set_cache_value($key, $value, $ttl);
- }
- return $value;
-}
-
# set up the visitor's language
#
function set_lang() {