[PATCH 0/1] Update cache code to INI style configuration
This updates the cache code to make it possible to enable memcache for the cache of MySQL data. I couldn't get APC working and can't figure out if Arch still supports it, I'd suggest getting rid of it. Would you accept more patches to use memcache caching? Jelle van der Waa (1): Update cache code to INI style configuration INSTALL | 6 ++++++ conf/config.proto | 3 +++ web/lib/cachefuncs.inc.php | 10 +++------- 3 files changed, 12 insertions(+), 7 deletions(-) -- 2.16.2
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
On Fri, 09 Mar 2018 at 23:42:51, Jelle van der Waa wrote:
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(-) [...]
Great idea. Merged, thanks!
participants (2)
-
Jelle van der Waa
-
Lukas Fleischer