Bugzilla – Attachment 184895 Details for
Bug 40554
Improve performance using a cache for AV descriptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40554: Use a dedicated namespace for AVs
Bug-40554-Use-a-dedicated-namespace-for-AVs.patch (text/plain), 5.68 KB, created by
Jonathan Druart
on 2025-07-30 14:14:47 UTC
(
hide
)
Description:
Bug 40554: Use a dedicated namespace for AVs
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-07-30 14:14:47 UTC
Size:
5.68 KB
patch
obsolete
>From efc21668f04cee36a78d178d6f13adb121571d6e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 30 Jul 2025 16:12:40 +0200 >Subject: [PATCH] Bug 40554: Use a dedicated namespace for AVs > >--- > C4/Biblio.pm | 18 ++++++++++-------- > C4/Koha.pm | 4 ++-- > Koha/AuthorisedValue.pm | 8 ++++++-- > Koha/AuthorisedValues.pm | 4 ++-- > 4 files changed, 20 insertions(+), 14 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 00f481cf965..6616d9de696 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1501,15 +1501,14 @@ sub GetAuthorisedValueDesc { > > return q{} unless defined($value); > >- my $cache = Koha::Caches->get_instance(); >- my $cache_key; > if ( !$category ) { > > return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'}; > > #---- branch > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) { >- $cache_key = "libraries:name"; >+ my $cache = Koha::Caches->get_instance(); >+ my $cache_key = "libraries:name"; > my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$libraries ) { > $libraries = { >@@ -1525,10 +1524,11 @@ sub GetAuthorisedValueDesc { > > #---- itemtypes > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) { >- my $lang = C4::Languages::getlanguage; >+ my $cache = Koha::Caches->get_instance(); >+ my $lang = C4::Languages::getlanguage; > $lang //= 'en'; >- $cache_key = 'itemtype:description:' . $lang; >- my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); >+ my $cache_key = 'itemtype:description:' . $lang; >+ my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$itypes ) { > $itypes = { map { $_->itemtype => $_->translated_description } Koha::ItemTypes->search()->as_list }; > $cache->set_in_cache( $cache_key, $itypes ); >@@ -1537,7 +1537,8 @@ sub GetAuthorisedValueDesc { > } > > if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) { >- $cache_key = "cn_sources:description"; >+ my $cache = Koha::Caches->get_instance(); >+ my $cache_key = "cn_sources:description"; > my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$cn_sources ) { > $cn_sources = { >@@ -1557,7 +1558,8 @@ sub GetAuthorisedValueDesc { > > my $dbh = C4::Context->dbh; > if ( $category ne "" ) { >- $cache_key = "AV_descriptions:" . $category; >+ my $cache = Koha::Caches->get_instance('authorised-values'); >+ my $cache_key = "AV_descriptions:" . $category; > my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); > if ( !$av_descriptions ) { > $av_descriptions = { >diff --git a/C4/Koha.pm b/C4/Koha.pm >index bee096db9fc..c7f91c78535 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -515,7 +515,7 @@ sub GetAuthorisedValues { > # Is this cached already? > my $branch_limit = C4::Context::mybranch(); > my $cache_key = "AuthorisedValues-$category-$opac-$branch_limit"; >- my $cache = Koha::Caches->get_instance(); >+ my $cache = Koha::Caches->get_instance('authorised-values'); > my $result = $cache->get_from_cache($cache_key); > return $result if $result; > >@@ -560,7 +560,7 @@ sub GetAuthorisedValues { > } > $sth->finish; > >- $cache->set_in_cache( $cache_key, \@results, { expiry => 5 } ); >+ $cache->set_in_cache( $cache_key, \@results ); > return \@results; > } > >diff --git a/Koha/AuthorisedValue.pm b/Koha/AuthorisedValue.pm >index 7a306bfae52..ab58d7e0b9b 100644 >--- a/Koha/AuthorisedValue.pm >+++ b/Koha/AuthorisedValue.pm >@@ -30,7 +30,7 @@ use base qw(Koha::Object Koha::Object::Limit::Library); > use constant NUM_PATTERN => q{^(-[1-9][0-9]*|0|[1-9][0-9]*)$}; > use constant NUM_PATTERN_JS => q{(-[1-9][0-9]*|0|[1-9][0-9]*)}; # ^ and $ removed > >-my $cache = Koha::Caches->get_instance(); >+my $cache = Koha::Caches->get_instance('authorised-values'); > > =head1 NAME > >@@ -70,6 +70,8 @@ sub store { > $self = $self->SUPER::store; > > if ($flush) { >+ >+ # FIXME Clear the whole authorised-values instance > my $key = "AV_descriptions:" . $self->category; > $cache->clear_from_cache($key); > } >@@ -85,7 +87,9 @@ AuthorisedValue specific C<delete> to clear relevant caches on delete. > > sub delete { > my $self = shift @_; >- my $key = "AV_descriptions:" . $self->category; >+ >+ # FIXME Clear the whole authorised-values instance >+ my $key = "AV_descriptions:" . $self->category; > $cache->clear_from_cache($key); > $self->SUPER::delete(@_); > } >diff --git a/Koha/AuthorisedValues.pm b/Koha/AuthorisedValues.pm >index 709bffb93cf..170cf2bcd9f 100644 >--- a/Koha/AuthorisedValues.pm >+++ b/Koha/AuthorisedValues.pm >@@ -55,7 +55,7 @@ sub find_description_by_code { > > # Is this cached already? > my $cache_key = "AuthorisedValues-$category-values-$value-$opac-$default_to_blank"; >- my $cache = Koha::Caches->get_instance(); >+ my $cache = Koha::Caches->get_instance('authorised-values'); > my $result = $cache->get_from_cache($cache_key); > return $result if $result; > >@@ -63,7 +63,7 @@ sub find_description_by_code { > > my $description = $av ? $opac ? $av->opac_description : $av->lib : $default_to_blank ? q{} : $value; > >- $cache->set_in_cache( $cache_key, $description, { expiry => 5 } ); >+ $cache->set_in_cache( $cache_key, $description ); > > return $description; > } >-- >2.34.1
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 40554
:
184893
|
184894
| 184895