Bug 16044: Populate the L1 cache when L2 is fetched
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 24 Mar 2016 20:47:47 +0000 (20:47 +0000)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Tue, 29 Mar 2016 22:26:40 +0000 (22:26 +0000)
The whole patch set is not very pertinent if the L1 cache is not
populated when L2 is fetched!
This patch fixes this inconsistency.

Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
Koha/Cache.pm

index d3d52ec..8370d3e 100644 (file)
@@ -329,7 +329,13 @@ sub get_from_cache {
     }
 
     my $get_sub = $self->{ref($self->{$cache}) . "_get"};
-    return $get_sub ? $get_sub->($key) : $self->{$cache}->get($key);
+    my $value = $get_sub ? $get_sub->($key) : $self->{$cache}->get($key);
+
+    # Update the L1 cache when fetching the L2 cache
+    # Otherwise the L1 cache won't ever be populated
+    $L1_cache{$key} = $value;
+
+    return $value;
 }
 
 =head2 clear_from_cache