Bugzilla – Attachment 190477 Details for
Bug 41440
Add caching to language_get_description and get_rfc4646_from_iso639
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41440: Add caching to language_get_description and get_rfc4646_from_iso639
Bug-41440-Add-caching-to-languagegetdescription-an.patch (text/plain), 2.06 KB, created by
David Nind
on 2025-12-13 07:23:26 UTC
(
hide
)
Description:
Bug 41440: Add caching to language_get_description and get_rfc4646_from_iso639
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-12-13 07:23:26 UTC
Size:
2.06 KB
patch
obsolete
>From d3e978af07afc37a5da3a9913adbb8266c8591e2 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 12 Dec 2025 14:29:39 +0000 >Subject: [PATCH] Bug 41440: Add caching to language_get_description and > get_rfc4646_from_iso639 > >This should have no visible effect, just internal caching > >To test: >1 - Do a search, check the language facets >2 - Apply patch, restart all >3 - Do a search, check the language facets >4 - No change >5 - Sign off > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/Languages.pm | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > >diff --git a/C4/Languages.pm b/C4/Languages.pm >index df8959ba5b..c79d2bb0c2 100644 >--- a/C4/Languages.pm >+++ b/C4/Languages.pm >@@ -480,6 +480,12 @@ Missing POD for language_get_description. > > sub language_get_description { > my ( $script, $lang, $type ) = @_; >+ >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >+ my $cache_key = "Language_descriptions:$script:$lang:$type"; >+ my $cached = $memory_cache->get_from_cache($cache_key); >+ return $cached if $cached; >+ > my $dbh = C4::Context->dbh; > my $desc; > my $sth = $dbh->prepare("SELECT description FROM language_descriptions WHERE subtag=? AND lang=? AND type=?"); >@@ -496,6 +502,7 @@ sub language_get_description { > $desc = $descriptions->{'description'}; > } > } >+ $memory_cache->set_in_cache( $cache_key, $desc ); > return $desc; > } > >@@ -797,9 +804,14 @@ sub getlanguage { > > sub get_rfc4646_from_iso639 { > >- my $iso_code = shift; >+ my $iso_code = shift; >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance; >+ my $cache_key = "RFC4646ByISO639:$iso_code"; >+ my $cached = $memory_cache->get_from_cache($cache_key); >+ return $cached if $cached; > my $rfc_subtag = > Koha::Database->new()->schema->resultset('LanguageRfc4646ToIso639')->find( { iso639_2_code => $iso_code } ); >+ $memory_cache->set_in_cache( $cache_key, $rfc_subtag ); > if ($rfc_subtag) { > return $rfc_subtag->rfc4646_subtag; > } else { >-- >2.39.5
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 41440
:
190466
| 190477