Skip to content

Commit

Permalink
Item13593: MetaCache not checking if cache exists
Browse files Browse the repository at this point in the history
This change reduced a problem search from >60 seconds  to 17 seconds.
Delivers same or slightly better performance now than 1.1.9
  • Loading branch information
gac410 committed Aug 3, 2015
1 parent 774bdbe commit 4e7a760
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/lib/Foswiki/MetaCache.pm
Expand Up @@ -144,6 +144,14 @@ sub removeMeta {
sub addMeta {
my ( $this, $web, $topic, $meta ) = @_;

my $user = $this->current_user();

# If the cache is already populated, return it, don't add it again
if ( $this->hasCached( $web, $topic ) ) {
print STDERR "Cache hit for $web.$topic for $user\n" if (TRACE);
return $this->{cache}->{$user}{$web}{$topic}->{tom};
}

if ( not defined($meta) ) {
$meta = Foswiki::Meta->load( $this->{session}, $web, $topic );
}
Expand All @@ -160,8 +168,6 @@ sub addMeta {
return;
}

my $user = $this->current_user();

unless ( $this->{cache}->{$user}{$web} ) {
$this->{cache}->{$user}{$web} = {};
}
Expand Down

0 comments on commit 4e7a760

Please sign in to comment.