[PATCH/RFC 22/24] gitweb: Support legacy options used by kernel.org caching engine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Try to translate between config variables used by gitweb caching
patches[1] by John 'Warthog9' Hawley (J.H.) used, among others, by
git.kernel.org, and new %cache_options options, but only if the legacy
config variables were set in the config file.

Note that $cache_enable is *not* translated to $caching_enabled.

Footnotes:
~~~~~~~~~~
[1] See for example "Gitweb caching v7" thread on git mailing list:
    http://thread.gmane.org/gmane.comp.version-control.git/160147

Signed-off-by: Jakub Narebski <jnareb@xxxxxxxxx>
---
This patch was not present in previous version of this series.

The drawback of this patch is that if any legacy config variable is set
in config file, then any change to %cache_options covering the same area
as legacy config variable would be ignored.  I don't see a better
solution, unless we can somehow check if value of %cache_options was
changed via gitweb config file.

I wonder how useful this patch would be; do people using caching from
"Gitweb caching v7" (caching feom git.kernel.org) configure it, or do
they use default configuration?

 gitweb/gitweb.perl |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 5904d27..1521bf2 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -284,6 +284,9 @@ our $caching_enabled = 0;
 # Suggested mechanism:
 # mv $cachedir $cachedir.flush && mkdir $cachedir && rm -rf $cachedir.flush
 our $cache;
+
+# Legacy options configuring behavior of git.kernel.org caching
+our ($minCacheTime, $maxCacheTime, $cachedir, $backgroundCache, $maxCacheLife);
 # You define site-wide cache options defaults here; override them with
 # $GITWEB_CONFIG as necessary.
 our %cache_options = (
@@ -1363,6 +1366,19 @@ sub configure_caching {
 		$cache ||= 'GitwebCache::FileCacheWithLocking';
 		eval "require $cache";
 		die $@ if $@;
+
+		# support for legacy config variables configuring cache behavior
+		# (those variables are/were used by caching engine by John Hawley,
+		# used among others by custom gitweb at http://git.kernel.org);
+		# it assumes that if those variables are defined, then we should
+		# use them - no provision is made for having both legacy variables
+		# and new %cache_options set in config file(s).
+		$cache_options{'cache_root'} = $cachedir if defined $cachedir;
+		$cache_options{'expires_min'} = $minCacheTime if defined $minCacheTime;
+		$cache_options{'expires_max'} = $maxCacheTime if defined $maxCacheTime;
+		$cache_options{'background_cache'} = $backgroundCache if defined $backgroundCache;
+		$cache_options{'max_lifetime'} = $maxCacheLife if defined $maxCacheLife;
+
 		$cache = $cache->new({
 			%cache_options,
 			#'cache_root' => '/tmp/cache',
-- 
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]