Bugzilla – Attachment 109670 Details for
Bug 26393
Add cache on Koha::CirculationRules::get_effective_rule
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26393: Add cache on Koha::CirculationRules::get_effective_rule
Bug-26393-Add-cache-on-KohaCirculationRulesgeteffe.patch (text/plain), 1.92 KB, created by
Fridolin Somers
on 2020-09-04 15:28:13 UTC
(
hide
)
Description:
Bug 26393: Add cache on Koha::CirculationRules::get_effective_rule
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2020-09-04 15:28:13 UTC
Size:
1.92 KB
patch
obsolete
>From 00c43a72d1a696d551b49170c1871c20aa4c66af Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Fri, 4 Sep 2020 17:25:24 +0200 >Subject: [PATCH] Bug 26393: Add cache on > Koha::CirculationRules::get_effective_rule > >For performance of several circulation pages we should cache the result of method Koha::CirculationRules::get_effective_rule. > >Adds a constant CACHE_NO_CIRCULATION_RULE_VALUE to store a special >value when method must return undef. >--- > Koha/CirculationRules.pm | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index 87062f541a..478c9a8831 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -26,6 +26,7 @@ use Koha::CirculationRule; > use base qw(Koha::Objects); > > use constant GUESSED_ITEMTYPES_KEY => 'Koha_IssuingRules_last_guess'; >+use constant CACHE_NO_CIRCULATION_RULE_VALUE => 'NONE'; > > =head1 NAME > >@@ -190,6 +191,21 @@ sub get_effective_rule { > "Required parameter 'rule_name' missing") > unless $rule_name; > >+ my $cache = Koha::Caches->get_instance(); >+ my $cache_key = 'CirculationRule_get_effective_rule-'.$rule_name; >+ foreach ( $branchcode, $categorycode, $itemtype ) { >+ $cache_key .= '-'.($_ ? $_ : ''); >+ } >+ my $cached = $cache->get_from_cache($cache_key); >+ if ($cached) { >+ if ( ref $cached eq 'SCALAR' && $cached eq CACHE_NO_CIRCULATION_RULE_VALUE ) { >+ return undef; >+ } >+ my $cr = Koha::CirculationRule->new($cached); >+ $cr->{_result}->in_storage(1); # Tell it exists in DB >+ return $cr; >+ } >+ > for my $v ( $branchcode, $categorycode, $itemtype ) { > $v = undef if $v and $v eq '*'; > } >@@ -212,6 +228,8 @@ sub get_effective_rule { > } > )->single; > >+ $cache->set_in_cache( $cache_key, $rule ? $rule->unblessed : CACHE_NO_CIRCULATION_RULE_VALUE ); >+ > return $rule; > } > >-- >2.27.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 26393
:
109670
|
109827
|
109839
|
109840
|
109846