Bugzilla – Attachment 49490 Details for
Bug 16044
Define a L1 cache for all objects set in cache
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16044: Use the L2 cache for any objects set in cache
Bug-16044-Use-the-L2-cache-for-any-objects-set-in-.patch (text/plain), 5.14 KB, created by
Jesse Weaver
on 2016-03-23 23:04:39 UTC
(
hide
)
Description:
Bug 16044: Use the L2 cache for any objects set in cache
Filename:
MIME Type:
Creator:
Jesse Weaver
Created:
2016-03-23 23:04:39 UTC
Size:
5.14 KB
patch
obsolete
>From dd2453830cad0d15a7f3eb6bf6280be4f2ac6d78 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 10 Mar 2016 15:54:28 +0000 >Subject: [PATCH] Bug 16044: Use the L2 cache for any objects set in cache > >Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com> >--- > C4/Context.pm | 14 -------------- > Koha/Cache.pm | 22 ++++++++++++++++++++++ > debian/templates/plack.psgi | 2 +- > misc/plack/koha.psgi | 3 ++- > 4 files changed, 25 insertions(+), 16 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index bae5f12..4c5f508 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -505,7 +505,6 @@ with this method. > =cut > > my $syspref_cache = Koha::Cache->get_instance(); >-my %syspref_L1_cache; > my $use_syspref_cache = 1; > sub preference { > my $self = shift; >@@ -513,11 +512,6 @@ sub preference { > > $var = lc $var; > >- # Return the value if the var has already been accessed >- if ($use_syspref_cache && exists $syspref_L1_cache{$var}) { >- return $syspref_L1_cache{$var}; >- } >- > my $cached_var = $use_syspref_cache > ? $syspref_cache->get_from_cache("syspref_$var") > : undef; >@@ -534,7 +528,6 @@ sub preference { > > if ( $use_syspref_cache ) { > $syspref_cache->set_in_cache("syspref_$var", $value); >- $syspref_L1_cache{$var} = $value; > } > return $value; > } >@@ -590,11 +583,6 @@ will not be seen by this process. > sub clear_syspref_cache { > return unless $use_syspref_cache; > $syspref_cache->flush_all; >- clear_syspref_L1_cache() >-} >- >-sub clear_syspref_L1_cache { >- %syspref_L1_cache = (); > } > > =head2 set_preference >@@ -647,7 +635,6 @@ sub set_preference { > > if ( $use_syspref_cache ) { > $syspref_cache->set_in_cache( "syspref_$variable", $value ); >- $syspref_L1_cache{$variable} = $value; > } > > return $syspref; >@@ -669,7 +656,6 @@ sub delete_preference { > if ( Koha::Config::SysPrefs->find( $var )->delete ) { > if ( $use_syspref_cache ) { > $syspref_cache->clear_from_cache("syspref_$var"); >- delete $syspref_L1_cache{$var}; > } > > return 1; >diff --git a/Koha/Cache.pm b/Koha/Cache.pm >index 9856e80..39a16d0 100644 >--- a/Koha/Cache.pm >+++ b/Koha/Cache.pm >@@ -46,6 +46,8 @@ use base qw(Class::Accessor); > __PACKAGE__->mk_ro_accessors( > qw( cache memcached_cache fastmmap_cache memory_cache )); > >+our %L1_cache; >+ > =head2 get_instance > > my $cache = Koha::Cache->get_instance(); >@@ -277,6 +279,10 @@ sub set_in_cache { > my $expiry = $options->{expiry}; > $expiry //= $self->{timeout}; > my $set_sub = $self->{ref($self->{$cache}) . "_set"}; >+ >+ # Set in L1 cache >+ $L1_cache{ $key } = $value; >+ > # We consider an expiry of 0 to be inifinite > if ( $expiry ) { > return $set_sub >@@ -305,6 +311,10 @@ sub get_from_cache { > croak "No key" unless $key; > $ENV{DEBUG} && carp "get_from_cache for $key"; > return unless ( $self->{$cache} && ref( $self->{$cache} ) =~ m/^Cache::/ ); >+ >+ # Return L1 cache value if exists >+ return $L1_cache{$key} if exists $L1_cache{$key}; >+ > my $get_sub = $self->{ref($self->{$cache}) . "_get"}; > return $get_sub ? $get_sub->($key) : $self->{$cache}->get($key); > } >@@ -323,6 +333,10 @@ sub clear_from_cache { > $cache ||= 'cache'; > croak "No key" unless $key; > return unless ( $self->{$cache} && ref( $self->{$cache} ) =~ m/^Cache::/ ); >+ >+ # Clear from L1 cache >+ delete $L1_cache{$key}; >+ > return $self->{$cache}->delete($key) > if ( ref( $self->{$cache} ) =~ m'^Cache::Memcached' ); > return $self->{$cache}->remove($key); >@@ -340,11 +354,19 @@ sub flush_all { > my ( $self, $cache ) = shift; > $cache ||= 'cache'; > return unless ( $self->{$cache} && ref( $self->{$cache} ) =~ m/^Cache::/ ); >+ >+ $self->flush_L1_cache(); >+ > return $self->{$cache}->flush_all() > if ( ref( $self->{$cache} ) =~ m'^Cache::Memcached' ); > return $self->{$cache}->clear(); > } > >+sub flush_L1_cache { >+ my( $self ) = @_; >+ %L1_cache = (); >+} >+ > =head1 TIED INTERFACE > > Koha::Cache also provides a tied interface which enables users to provide a >diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi >index b6bd67f..995fa72 100644 >--- a/debian/templates/plack.psgi >+++ b/debian/templates/plack.psgi >@@ -44,7 +44,7 @@ use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise > *CGI::new = sub { > my $q = $old_new->( @_ ); > $CGI::PARAM_UTF8 = 1; >- C4::Context->clear_syspref_L1_cache(); >+ Koha::Cache->flush_L1_cache(); > return $q; > }; > } >diff --git a/misc/plack/koha.psgi b/misc/plack/koha.psgi >index 947bb02..d14755d 100644 >--- a/misc/plack/koha.psgi >+++ b/misc/plack/koha.psgi >@@ -12,7 +12,7 @@ use CGI qw(-utf8 ); # we will loose -utf8 under plack > *CGI::new = sub { > my $q = $old_new->( @_ ); > $CGI::PARAM_UTF8 = 1; >- C4::Context->clear_syspref_L1_cache(); >+ Koha::Cache->flush_L1_cache(); > return $q; > }; > } >@@ -45,6 +45,7 @@ use C4::XSLT; > use C4::Branch; > use C4::Category; > use Koha::DateUtils; >+use Koha::Cache; > =for preload > use C4::Tags; # FIXME > =cut >-- >2.7.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16044
:
48968
|
49179
|
49186
|
49187
|
49188
|
49239
|
49240
|
49490
|
49491
|
49492
|
49493
|
49494
|
49545
|
49546
|
49547
|
49548
|
49549
|
49555
|
49568
|
49647