added a per-site config file option for international message caching

This commit is contained in:
JT Smith 2004-02-22 21:50:29 +00:00
parent 35ead8b39e
commit 3eec10dc49
11 changed files with 59 additions and 55 deletions

View file

@ -77,8 +77,9 @@ webgui.
to allow templates to be hidden from forms and/or management. to allow templates to be hidden from forms and/or management.
- Added dTree menu to the navigation system - Added dTree menu to the navigation system
(Thanks to Geir Landro, http://www.destroydrop.com) (Thanks to Geir Landro, http://www.destroydrop.com)
- Added Cool Menus to the navigation system. (Thanks to Thomas Bratili, - Added Cool Menus to the navigation system. (Thanks to Thomas Brattli,
http://www.dhtmlcentral.com) http://www.dhtmlcentral.com)
- Added a config file option for per-site International message caching.

View file

@ -82,8 +82,6 @@ Convert::ASN1........................Graham Barr
Data::Config.........................Sébastien Aperghis-Tramoni Data::Config.........................Sébastien Aperghis-Tramoni
HTML::CalendarMonthSimple............Gregor Mosheh
HTML::TagFilter......................William Ross HTML::TagFilter......................William Ross
HTML::Template.......................Sam Tregar HTML::Template.......................Sam Tregar

View file

@ -26,6 +26,7 @@ save you many hours of grief.
* WebGUI now requires the following Perl modules to be installed: * WebGUI now requires the following Perl modules to be installed:
Data::Serializer Data::Serializer
SOAP::Lite SOAP::Lite
Cache::Cache (no longer optional)
WARNING: Be sure you install these modules BEFORE you attempt to WARNING: Be sure you install these modules BEFORE you attempt to
upgrade or the upgrade will fail and you'll have a mess to upgrade or the upgrade will fail and you'll have a mess to
@ -36,6 +37,7 @@ save you many hours of grief.
calendars. Your old templates will remain intact, however, calendars. Your old templates will remain intact, however,
so that you can migrate them manually to the new template so that you can migrate them manually to the new template
variables. variables.
5.5.0 5.5.0

View file

@ -26,7 +26,7 @@ QnD INSTALL INSTRUCTIONS:
SOAP::Lite SOAP::Lite
Data::Serializer Data::Serializer
Image::Magick (optional) Image::Magick (optional)
Cache::Cache (optional) Cache::Cache
3. Install Apache (preferably with mod_perl) and set up your config. 3. Install Apache (preferably with mod_perl) and set up your config.

View file

@ -500,6 +500,7 @@ push(@newWobjects,"WSClient");
$conf->set("wobjects"=>\@newWobjects); $conf->set("wobjects"=>\@newWobjects);
$conf->set("emailRecoveryLoggingEnabled"=>1); $conf->set("emailRecoveryLoggingEnabled"=>1);
$conf->set("passwordChangeLoggingEnabled"=>1); $conf->set("passwordChangeLoggingEnabled"=>1);
$conf->set("useSharedInternationalCache"=>1);
$conf->write; $conf->write;

File diff suppressed because one or more lines are too long

View file

@ -12,6 +12,11 @@ extrasPath = /data/WebGUI/www/extras
uploadsURL = /uploads uploadsURL = /uploads
uploadsPath = /data/WebGUI/www/uploads uploadsPath = /data/WebGUI/www/uploads
useSharedInternationalCache = 1
emailRecoveryLoggingEnabled = 1
passwordChangeLoggingEnabled = 1
authMethods = LDAP, WebGUI authMethods = LDAP, WebGUI
wobjects = Article, EventsCalendar, FileManager, HttpProxy, \ wobjects = Article, EventsCalendar, FileManager, HttpProxy, \

View file

@ -15,9 +15,7 @@ package WebGUI::Cache;
=cut =cut
#Test to see if Cache::FileCache will load. use Cache::FileCache;
my $hasCache=1;
eval " use Cache::FileCache; "; $hasCache=0 if $@;
use HTTP::Headers; use HTTP::Headers;
use HTTP::Request; use HTTP::Request;
@ -32,7 +30,7 @@ Package WebGUI::Cache
=head1 DESCRIPTION =head1 DESCRIPTION
This package provides a means for WebGUI to cache data to the filesystem. Caching is only enabled, however, if Cache::Filecache is installed on the system. This package provides a means for WebGUI to cache data to the filesystem.
=head1 SYNOPSIS =head1 SYNOPSIS
@ -45,11 +43,6 @@ These methods are available from this class:
=cut =cut
#-------------------------------------------------------------------
sub _canCache {
return ($hasCache);
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -61,11 +54,7 @@ Remove content from the filesystem cache.
=cut =cut
sub delete { sub delete {
if (_canCache()) { $_[0]->{_cache}->remove($_[0]->{_key});
$_[0]->{_cache}->remove($_[0]->{_key});
} else {
$_[0]->{_cache} = "";
}
} }
@ -86,16 +75,12 @@ A regular expression that will match keys in the current namespace. Example: m/^
=cut =cut
sub deleteByRegex { sub deleteByRegex {
if (_canCache()) {
my @keys = $_[0]->{_cache}->get_keys(); my @keys = $_[0]->{_cache}->get_keys();
foreach my $key (@keys) { foreach my $key (@keys) {
if ($key =~ $_[1]) { if ($key =~ $_[1]) {
$_[0]->{_cache}->remove($key); $_[0]->{_cache}->remove($key);
} }
} }
} else {
$_[0]->{_cache} = "";
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -107,11 +92,7 @@ Retrieve content from the filesystem cache.
=cut =cut
sub get { sub get {
if (_canCache()) {
return $_[0]->{_cache}->get($_[0]->{_key}); return $_[0]->{_cache}->get($_[0]->{_key});
} else {
return $_[0]->{_cache};
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -124,12 +105,8 @@ Retrieves an datastructure from the filesystem cache.
sub getDataStructure { sub getDataStructure {
my ($serializer); my ($serializer);
if (_canCache()) {
$serializer = Data::Serializer->new(serializer => 'Storable'); $serializer = Data::Serializer->new(serializer => 'Storable');
return $serializer->deserialize($_[0]->{_cache}->get($_[0]->{_key})); return $serializer->deserialize($_[0]->{_cache}->get($_[0]->{_key}));
} else {
return $_[0]->{_cache};
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -157,7 +134,7 @@ sub new {
my $class = shift; my $class = shift;
my $key = shift; my $key = shift;
my $namespace = shift || $session{config}{configFile}; my $namespace = shift || $session{config}{configFile};
$cache = new Cache::FileCache({namespace=>$namespace, auto_purge_on_set=>1}) if (_canCache()); $cache = new Cache::FileCache({namespace=>$namespace, auto_purge_on_set=>1});
bless {_cache => $cache, _key => $key}, $class; bless {_cache => $cache, _key => $key}, $class;
} }
@ -184,11 +161,7 @@ The time to live for this content. This is the amount of time (in seconds) that
sub set { sub set {
my $ttl = $_[2] || 60; my $ttl = $_[2] || 60;
if (_canCache()) {
$_[0]->{_cache}->set($_[0]->{_key},$_[1],$ttl); $_[0]->{_cache}->set($_[0]->{_key},$_[1],$ttl);
} else {
$_[0]->{_cache} = $_[1];
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -217,12 +190,8 @@ in the cache. Defaults to "60".
sub setDataStructure { sub setDataStructure {
my $ttl = $_[2] || 60; my $ttl = $_[2] || 60;
if (_canCache()) {
$serializer = Data::Serializer->new(serializer => 'Storable'); $serializer = Data::Serializer->new(serializer => 'Storable');
$_[0]->{_cache}->set($_[0]->{_key},$serializer->serialize($_[1]),$ttl); $_[0]->{_cache}->set($_[0]->{_key},$serializer->serialize($_[1]),$ttl);
} else {
$_[0]->{_cache} = $_[1];
}
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -80,7 +80,11 @@ sub get {
} else { } else {
$namespace = "WebGUI"; $namespace = "WebGUI";
} }
$cache = WebGUI::Cache->new($language."_".$namespace."_".$_[0],"International"); my $cachetag = $session{config}{configFile}."-International";
if ($session{config}{useSharedInternationalCache}) {
$cachetag = "International";
}
$cache = WebGUI::Cache->new($language."_".$namespace."_".$_[0],$cachetag);
$output = $cache->get; $output = $cache->get;
if (not defined $output) { if (not defined $output) {
($output) = WebGUI::SQL->quickArray("select message from international ($output) = WebGUI::SQL->quickArray("select message from international

View file

@ -17,7 +17,7 @@ use Apache::Registry (); # Uncomment this for use with mod_perl 1.0
#---------------------------------------- #----------------------------------------
# System controlled Perl modules. # System controlled Perl modules.
#---------------------------------------- #----------------------------------------
eval "use Cache::FileCache ();"; # eval, may not be installed use Cache::FileCache ();
use CGI (); CGI->compile(':all'); use CGI (); CGI->compile(':all');
use CGI::Carp (); use CGI::Carp ();
use CGI::Util (); use CGI::Util ();
@ -29,6 +29,8 @@ use FileHandle ();
use Net::SMTP (); use Net::SMTP ();
use POSIX (); use POSIX ();
use URI::Escape (); use URI::Escape ();
use Data::Serializer ();
use SOAP::Lite ();
#---------------------------------------- #----------------------------------------

View file

@ -187,23 +187,45 @@ if (eval { require Date::Calc }) {
} }
} }
print "Cache::FileCache module (optional*) ...... "; print "Cache::Cache module ...................... ";
if (eval { require Cache::FileCache }) { if (eval { require Cache::Cache }) {
print "OK\n"; print "OK\n";
} else { } else {
print "Not installed. Caching not possible.\n"; if ($< == 0 && $os eq "Linuxish") {
print "Attempting to install...\n";
CPAN::Shell->install("Cache::Cache");
} else {
print "Please install.\n";
$prereq = 0;
}
} }
print <<STOP; print "SOAP::Lite module ........................ ";
if (eval { require SOAP::Lite }) {
print "OK\n";
} else {
if ($< == 0 && $os eq "Linuxish") {
print "Attempting to install...\n";
CPAN::Shell->install("SOAP::Lite");
} else {
print "Please install.\n";
$prereq = 0;
}
}
* Please note that Cache::FileCache is not print "Data::Serializer module .................. ";
optional in all environments (such as Mac if (eval { require Data::Serializer }) {
OS X). Also note, that Cache::FileCache print "OK\n";
is not available for Windows style } else {
environments due to limitations on those if ($< == 0 && $os eq "Linuxish") {
systems. print "Attempting to install...\n";
CPAN::Shell->install("Data::Serializer");
} else {
print "Please install.\n";
$prereq = 0;
}
}
STOP
print "Image::Magick module (optional) .......... "; print "Image::Magick module (optional) .......... ";
if (eval { require Image::Magick }) { if (eval { require Image::Magick }) {