diff options
author | Jelle van der Waa <jelle@vdwaa.nl> | 2018-03-09 23:42:51 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2018-03-10 16:48:14 +0100 |
commit | ca6332de6e33be645e1abab3434237805b8f7dfa (patch) | |
tree | 19348337f6477324a297d8a4384167a0c3851d49 | |
parent | c3bca45973c8ec351f8b41421705dec7d7a620e2 (diff) | |
download | aur-ca6332de6e33be645e1abab3434237805b8f7dfa.tar.gz aur-ca6332de6e33be645e1abab3434237805b8f7dfa.tar.xz |
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 <jelle@vdwaa.nl>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rw-r--r-- | INSTALL | 6 | ||||
-rw-r--r-- | conf/config.proto | 3 | ||||
-rw-r--r-- | web/lib/cachefuncs.inc.php | 10 |
3 files changed, 12 insertions, 7 deletions
@@ -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. diff --git a/conf/config.proto b/conf/config.proto index 934d3697..be37f430 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 [ratelimit] request_limit = 4000 diff --git a/web/lib/cachefuncs.inc.php b/web/lib/cachefuncs.inc.php index faeae5a2..881ad8f2 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); |