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 <jelle@vdwaa.nl> --- INSTALL | 6 ++++++ conf/config.proto | 3 +++ web/lib/cachefuncs.inc.php | 10 +++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/INSTALL b/INSTALL index ba24a45..54f66dd 100644 --- a/INSTALL +++ b/INSTALL @@ -93,3 +93,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. diff --git a/conf/config.proto b/conf/config.proto index 1750929..08cfb1d 100644 --- a/conf/config.proto +++ b/conf/config.proto @@ -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 [notifications] notify-cmd = /usr/local/bin/aurweb-notify diff --git a/web/lib/cachefuncs.inc.php b/web/lib/cachefuncs.inc.php index faeae5a..881ad8f 100644 --- a/web/lib/cachefuncs.inc.php +++ b/web/lib/cachefuncs.inc.php @@ -1,22 +1,18 @@ <?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); -- 2.16.2