Skip to content

Commit

Permalink
Item12252: improved save performance on large webs
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/DBCachePlugin@16061 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Nov 19, 2012
1 parent 8456b5e commit 6f84d19
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
3 changes: 2 additions & 1 deletion data/System/DBCachePlugin.txt
Expand Up @@ -412,7 +412,8 @@ when the user has got view access to the target topic.
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 1 Oct 2012: | handle bad date formfields more gracefully |
| 19 Nov 2012: | improved save performance on large webs |
| 01 Oct 2012: | handle bad date formfields more gracefully |
| 11 Jan 2012: | implemented !TopicTitles protected by access control rights |
| 10 Jan 2012: | implemented DBPREV and DBNEXT; \
rationalized rendering !TopicTitles instead of the normal !WikiWord linktext; \
Expand Down
27 changes: 14 additions & 13 deletions lib/Foswiki/Plugins/DBCachePlugin.pm
Expand Up @@ -14,24 +14,25 @@

package Foswiki::Plugins::DBCachePlugin;

use strict;
use warnings;

#use Monitor;
#Monitor::MonitorMethod('Foswiki::Contrib::DBCachePlugin');
#Monitor::MonitorMethod('Foswiki::Contrib::DBCachePlugin::Core');
#Monitor::MonitorMethod('Foswiki::Contrib::DBCachePlugin::WebDB');

use strict;
use vars qw(
$VERSION $RELEASE $SHORTDESCRIPTION $NO_PREFS_IN_TOPIC
$baseWeb $baseTopic $isInitialized
$addDependency
$isEnabledSaveHandler
$isEnabledRenameHandler
);

$VERSION = '$Rev$';
$RELEASE = '4.11';
$NO_PREFS_IN_TOPIC = 1;
$SHORTDESCRIPTION = 'Lightweighted frontend to the DBCacheContrib';
our $VERSION = '4.20';
our $RELEASE = '4.20';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Lightweighted frontend to the DBCacheContrib';

our $baseWeb;
our $baseTopic;
our $isInitialized;
our $addDependency;
our $isEnabledSaveHandler;
our $isEnabledRenameHandler;

###############################################################################
# plugin initializer
Expand Down
13 changes: 10 additions & 3 deletions lib/Foswiki/Plugins/DBCachePlugin/Core.pm
Expand Up @@ -113,8 +113,7 @@ sub afterSaveHandler {

#writeDebug("called afterSaveHandler($web, $topic, $newWeb, $newTopic, ..., ...)");

my $doFullUpdate = $Foswiki::cfg{DBCacheContrib}{AlwaysUpdateCache};
$doFullUpdate = 1 unless defined $doFullUpdate;
my $doFullUpdate = $Foswiki::cfg{DBCacheContrib}{AlwaysUpdateCache} || 0;

$newWeb ||= $baseWeb;
$newTopic ||= $baseTopic;
Expand All @@ -141,12 +140,20 @@ sub afterSaveHandler {
} else {
$db->loadTopic($web, $newTopic)
}

# set the internal loadTime counter to the latest modification
# time on disk.
$db->updateLoadTime;

} else { # crossing webs
$db = getDB($newWeb);
$db->loadTopic($newWeb, $topic);
if ($topic ne $newTopic) {
$db->loadTopic($newWeb, $newTopic)
}

# same
$db->updateLoadTime;
}
}
}
Expand Down Expand Up @@ -1105,7 +1112,7 @@ sub formatRecursive {
sub getDB {
my ($theWeb, $refresh) = @_;

writeDebug("called getDB($theWeb)");
#writeDebug("called getDB($theWeb)");

unless(Foswiki::Sandbox::validateWebName($theWeb, 1)) {
if (DEBUG) {
Expand Down
15 changes: 12 additions & 3 deletions lib/Foswiki/Plugins/DBCachePlugin/WebDB.pm
Expand Up @@ -71,7 +71,14 @@ sub load {
# load the rest of the database
$this->SUPER::load($refresh);

# then get the time stamp
# set the time stamp
$this->updateLoadTime;
}

###############################################################################
sub updateLoadTime {
my $this = shift;

$this->{_loadTime} = $this->_getModificationTime();
}

Expand All @@ -81,7 +88,7 @@ sub _getCacheFile {
my $this = shift;

my $cacheFile = $this->getArchivist()->{_file};
writeDebug("cacheFile=$cacheFile");
#writeDebug("cacheFile=$cacheFile");
return $cacheFile if -f $cacheFile;

writeDebug("cacheFile $cacheFile not found");
Expand Down Expand Up @@ -114,7 +121,9 @@ sub touch {
sub isModified {
my $this = shift;

return 1 if $this->_getModificationTime() == 0 || $this->{_loadTime} < $this->_getModificationTime();
my $time = $this->_getModificationTime();

return 1 if $time == 0 || $this->{_loadTime} < $time;
return 0;
}

Expand Down

0 comments on commit 6f84d19

Please sign in to comment.