Commit ca6332de authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by Lukas Fleischer
Browse files

Update cache code to INI style configuration



Change the defines to config_get and add one cache option and one option
to define memcache_servers. Mention the required dependency to get
memcached working in the INSTALL file.
Signed-off-by: Jelle van der Waa's avatarJelle van der Waa <jelle@vdwaa.nl>
Signed-off-by: Lukas Fleischer's avatarLukas Fleischer <lfleischer@archlinux.org>
parent c3bca459
......@@ -95,3 +95,9 @@ read the instructions below.
}
Sample systemd unit files for fcgiwrap can be found under conf/.
10) If you want memcache to cache MySQL data.
# pacman -S php-memcached
And edit the configuration file to enabled memcache caching.
......@@ -35,6 +35,9 @@ snapshot_uri = /cgit/aur.git/snapshot/%s.tar.gz
enable-maintenance = 1
maintenance-exceptions = 127.0.0.1
render-comment-cmd = /usr/local/bin/aurweb-rendercomment
# memcache or apc
cache = none
memcache_servers = 127.0.0.1:11211
[ratelimit]
request_limit = 4000
......
<?php
if (!defined('CACHE_TYPE')) {
define('CACHE_TYPE', 'NONE');
}
# Check if APC extension is loaded, and set cache prefix if it is.
if (CACHE_TYPE == 'APC' && !defined('EXTENSION_LOADED_APC')) {
if (config_get('options', 'cache') == 'apc' && !defined('EXTENSION_LOADED_APC')) {
define('EXTENSION_LOADED_APC', extension_loaded('apc'));
define('CACHE_PREFIX', 'aur:');
}
# Check if memcache extension is loaded, and set cache prefix if it is.
if (CACHE_TYPE == 'MEMCACHE' && !defined('EXTENSION_LOADED_MEMCACHE')) {
if (config_get('options', 'cache') == 'memcache' && !defined('EXTENSION_LOADED_MEMCACHE')) {
define('EXTENSION_LOADED_MEMCACHE', extension_loaded('memcached'));
define('CACHE_PREFIX', 'aur:');
global $memcache;
$memcache = new Memcached();
$mcs = defined('MEMCACHE_SERVERS') ? MEMCACHE_SERVERS : '127.0.0.1:11211';
$mcs = config_get('options', 'memcache_servers');
foreach (explode(',', $mcs) as $elem) {
$telem = trim($elem);
$mcserver = explode(':', $telem);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment