From 46737d6945b79c5fe3ae4a76f290c1b6643920c8 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 24 Sep 2009 23:28:45 -0500 Subject: [PATCH] starting migration to memcached --- docs/upgrades/upgrade_7.8.1-8.0.0.pl | 22 ++++ etc/WebGUI.conf.original | 21 ---- .../Workflow/Activity/CleanDatabaseCache.pm | 94 --------------- .../Workflow/Activity/CleanFileCache.pm | 107 ------------------ 4 files changed, 22 insertions(+), 222 deletions(-) delete mode 100644 lib/WebGUI/Workflow/Activity/CleanDatabaseCache.pm delete mode 100644 lib/WebGUI/Workflow/Activity/CleanFileCache.pm diff --git a/docs/upgrades/upgrade_7.8.1-8.0.0.pl b/docs/upgrades/upgrade_7.8.1-8.0.0.pl index 883bb77bc..00dff6aca 100644 --- a/docs/upgrades/upgrade_7.8.1-8.0.0.pl +++ b/docs/upgrades/upgrade_7.8.1-8.0.0.pl @@ -18,6 +18,7 @@ BEGIN { } use strict; +use File::Path qw/rmtree/; use Getopt::Long; use WebGUI::Session; use WebGUI::Storage; @@ -31,10 +32,31 @@ my $quiet; # this line required my $session = start(); # this line required moveMaintenance($session); +migrateToNewCache($session); finish($session); # this line required +#---------------------------------------------------------------------------- +sub migrateToNewCache { + my $session = shift; + print "\tMigrating to new cache " unless $quiet; + rmtree "../../lib/WebGUI/Cache"; + unlink "../../lib/WebGUI/Workflow/Activity/CleanDatabaseCache.pm"; + unlink "../../lib/WebGUI/Workflow/Activity/CleanFileCache.pm"; + my $config = $session->config; + $config->set("cacheServers" => [ { "socket" => "/data/wre/var/memcached.sock", "host" => "127.0.0.1", "port" => "11211" } ]); + $config->delete("disableCache"); + $config->delete("cacheType"); + $config->delete("fileCacheRoot"); + $config->deleteFromArray("workflowActivities/None", "WebGUI::Workflow::Activity::CleanDatabaseCache"); + $config->deleteFromArray("workflowActivities/None", "WebGUI::Workflow::Activity::CleanFileCache"); + my $db = $session->db; + $db->write("drop table cache"); + $db->write("delete from WorkflowActivity where className in ('WebGUI::Workflow::Activity::CleanDatabaseCache','WebGUI::Workflow::Activity::CleanFileCache')"); + print "DONE!\n" unless $quiet; +} + #---------------------------------------------------------------------------- sub moveMaintenance { my $session = shift; diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 392c75f9a..34e395040 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -88,25 +88,6 @@ #"webServerPort" : 80, -# What kind of cache do you wish to use? Available types are -# WebGUI::Cache::FileCache and WebGUI::Cache::Database. -# We highly recommend the database cache if you are running -# sites with more than a few hundred pages, or if you're -# running in a multi-server environment. The file cache is better -# for very small sites. - -"cacheType" : "WebGUI::Cache::FileCache", - -# Tell WebGUI where to store cached files. Defaults to the -# /tmp or c:\temp folder depending upon your operating system. - -# "fileCacheRoot" : "/path/to/cache", - -# Set this to 1 to disable WebGUI's caching subsystems. This is -# mainly useful for developers. - -"disableCache" : 0, - # The database connection string. It usually takes the form of # DBI::;host: @@ -857,8 +838,6 @@ "WebGUI::Workflow::Activity::ArchiveOldStories", "WebGUI::Workflow::Activity::ArchiveOldThreads", "WebGUI::Workflow::Activity::CalendarUpdateFeeds", - "WebGUI::Workflow::Activity::CleanDatabaseCache", - "WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory", "WebGUI::Workflow::Activity::CleanTempStorage", "WebGUI::Workflow::Activity::CreateCronJob", diff --git a/lib/WebGUI/Workflow/Activity/CleanDatabaseCache.pm b/lib/WebGUI/Workflow/Activity/CleanDatabaseCache.pm deleted file mode 100644 index bd7a241a4..000000000 --- a/lib/WebGUI/Workflow/Activity/CleanDatabaseCache.pm +++ /dev/null @@ -1,94 +0,0 @@ -package WebGUI::Workflow::Activity::CleanDatabaseCache; - - -=head1 LEGAL - - ------------------------------------------------------------------- - WebGUI is Copyright 2001-2009 Plain Black Corporation. - ------------------------------------------------------------------- - Please read the legal notices (docs/legal.txt) and the license - (docs/license.txt) that came with this distribution before using - this software. - ------------------------------------------------------------------- - http://www.plainblack.com info@plainblack.com - ------------------------------------------------------------------- - -=cut - -use strict; -use base 'WebGUI::Workflow::Activity'; -use WebGUI::Cache::Database; - -=head1 NAME - -Package WebGUI::Workflow::Activity::CleanDatabaseCache - -=head1 DESCRIPTION - -This activity deletes entries from the database cache if the cache size has gotten too big. - -=head1 SYNOPSIS - -See WebGUI::Workflow::Activity for details on how to use any activity. - -=head1 METHODS - -These methods are available from this class: - -=cut - - -#------------------------------------------------------------------- - -=head2 definition ( session, definition ) - -See WebGUI::Workflow::Activity::definition() for details. - -=cut - -sub definition { - my $class = shift; - my $session = shift; - my $definition = shift; - my $i18n = WebGUI::International->new($session, "Workflow_Activity_CleanDatabaseCache"); - push(@{$definition}, { - name=>$i18n->get("activityName"), - properties=> { - sizeLimit => { - fieldType=>"integer", - label=>$i18n->get("size limit"), - subtext=>$i18n->get("bytes"), - defaultValue=>100000000, - hoverHelp=>$i18n->get("size limit help") - } - } - }); - return $class->SUPER::definition($session,$definition); -} - - -#------------------------------------------------------------------- - -=head2 execute ( ) - -See WebGUI::Workflow::Activity::execute() for details. - -=cut - -sub execute { - my $self = shift; - my $size = $self->get("sizeLimit") + 10; - my $expiresModifier = 0; - my $cache = WebGUI::Cache::Database->new($self->session); - while ($size > $self->get("sizeLimit")) { - $size = $cache->getNamespaceSize($expiresModifier); - $expiresModifier += 60 * 30; # add 30 minutes each pass - } - return $self->COMPLETE; -} - - - -1; - - diff --git a/lib/WebGUI/Workflow/Activity/CleanFileCache.pm b/lib/WebGUI/Workflow/Activity/CleanFileCache.pm deleted file mode 100644 index c37cfcf0f..000000000 --- a/lib/WebGUI/Workflow/Activity/CleanFileCache.pm +++ /dev/null @@ -1,107 +0,0 @@ -package WebGUI::Workflow::Activity::CleanFileCache; - - -=head1 LEGAL - - ------------------------------------------------------------------- - WebGUI is Copyright 2001-2009 Plain Black Corporation. - ------------------------------------------------------------------- - Please read the legal notices (docs/legal.txt) and the license - (docs/license.txt) that came with this distribution before using - this software. - ------------------------------------------------------------------- - http://www.plainblack.com info@plainblack.com - ------------------------------------------------------------------- - -=cut - -use strict; -use base 'WebGUI::Workflow::Activity'; -use WebGUI::Cache::FileCache; - -=head1 NAME - -Package WebGUI::Workflow::Activity::CleanFileCache - -=head1 DESCRIPTION - -This activity deletes files from the file cache if the file cache has gotten too big. - -=head1 SYNOPSIS - -See WebGUI::Workflow::Activity for details on how to use any activity. - -=head1 METHODS - -These methods are available from this class: - -=cut - - -#------------------------------------------------------------------- - -=head2 definition ( session, definition ) - -See WebGUI::Workflow::Activity::definition() for details. - -=cut - -sub definition { - my $class = shift; - my $session = shift; - my $definition = shift; - my $i18n = WebGUI::International->new($session, "Workflow_Activity_CleanFileCache"); - push(@{$definition}, { - name=>$i18n->get("activityName"), - properties=> { - sizeLimit => { - fieldType=>"integer", - label=>$i18n->get("size limit"), - subtext=>$i18n->get("bytes"), - defaultValue=>100000000, - hoverHelp=>$i18n->get("size limit help") - } - } - }); - return $class->SUPER::definition($session,$definition); -} - - -#------------------------------------------------------------------- - -=head2 execute ( ) - -See WebGUI::Workflow::Activity::execute() for details. - -=cut - -sub execute { - my $self = shift; - my $size = $self->get("sizeLimit") + 10; - my $expiresModifier = 0; - - # Purge expired content cache - my $cache = WebGUI::Cache::FileCache->new($self->session); - while ($size > $self->get("sizeLimit")) { - $size = $cache->getNamespaceSize($expiresModifier); - $expiresModifier += 60 * 30; # add 30 minutes each pass - } - - $size = $self->get("sizeLimit") + 10; - $expiresModifier = 0; - - # Purge expired rss cache - my $rssCache = WebGUI::Cache::FileCache->new($self->session, undef, 'RSS'); - while ($size > $self->get("sizeLimit")) { - $size = $rssCache->getNamespaceSize($expiresModifier); - $expiresModifier += 60 * 30; # add 30 minutes each pass - } - - return $self->COMPLETE; -} - - - -1; - -