Bugzilla – Attachment 114876 Details for
Bug 27343
Use L1 cache for get_all_subpermissions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27343: Cache get_all_subpermissions return
Bug-27343-Cache-getallsubpermissions-return.patch (text/plain), 1.67 KB, created by
Jonathan Druart
on 2021-01-05 14:20:05 UTC
(
hide
)
Description:
Bug 27343: Cache get_all_subpermissions return
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-05 14:20:05 UTC
Size:
1.67 KB
patch
obsolete
>From 26169e1ee354d9069b511fcb4e17da76e74f3b9b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 5 Jan 2021 12:01:18 +0100 >Subject: [PATCH] Bug 27343: Cache get_all_subpermissions return > >The permissions are fetched for every hit, we should cache them in L1. >--- > C4/Auth.pm | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 6db8ee5b91..771c457fc5 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -33,6 +33,7 @@ use C4::Languages; > use C4::Search::History; > use Koha; > use Koha::Caches; >+use Koha::Cache::Memory::Lite; > use Koha::AuthUtils qw(get_script_name hash_password); > use Koha::Checkouts; > use Koha::DateUtils qw(dt_from_string); >@@ -2086,16 +2087,25 @@ of the subpermission. > =cut > > sub get_all_subpermissions { >+ >+ my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); >+ my $cache_key = "all_subpermissions"; >+ >+ my $cached = $memory_cache->get_from_cache($cache_key); >+ return $cached if $cached; >+ > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( "SELECT flag, code >+ my $permissions = $dbh->selectall_arrayref( q|SELECT flag, code > FROM permissions >- JOIN userflags ON (module_bit = bit)" ); >- $sth->execute(); >+ JOIN userflags ON (module_bit = bit)|, { Slice => {} } ); > > my $all_perms = {}; >- while ( my $perm = $sth->fetchrow_hashref ) { >+ for my $perm ( @$permissions ) { > $all_perms->{ $perm->{'flag'} }->{ $perm->{'code'} } = 1; > } >+ >+ $memory_cache->set_in_cache( $cache_key, $all_perms ); >+ > return $all_perms; > } > >-- >2.20.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 27343
: 114876