Bugzilla – Attachment 39233 Details for
Bug 14207
Improving circulation performance by caching yaml file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 14207: Improving circulation performance by caching yaml file
SIGNED-OFF-Bug-14207-Improving-circulation-perform.patch (text/plain), 3.91 KB, created by
Bernardo Gonzalez Kriegel
on 2015-05-16 00:25:36 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14207: Improving circulation performance by caching yaml file
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2015-05-16 00:25:36 UTC
Size:
3.91 KB
patch
obsolete
>From cc0867d8996292f475ffc0832f919a4ad260067f Mon Sep 17 00:00:00 2001 >From: Julian FIOL <julian.fiol@biblibre.com> >Date: Fri, 15 May 2015 12:06:01 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 14207: Improving circulation performance by > caching yaml file > >This patch improve circulation performance by caching yaml file > >With this patch we saved between 300ms and 500ms on circulation page. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Times can be different, but is a gain anyway. >Work as described following test plan (pdf) >No koha-qa errors >--- > C4/Utils/DataTables/ColumnsSettings.pm | 38 ++++++++++++++++++-------------- > 1 file changed, 21 insertions(+), 17 deletions(-) > >diff --git a/C4/Utils/DataTables/ColumnsSettings.pm b/C4/Utils/DataTables/ColumnsSettings.pm >index ed8d9ac..17b5f6a 100644 >--- a/C4/Utils/DataTables/ColumnsSettings.pm >+++ b/C4/Utils/DataTables/ColumnsSettings.pm >@@ -5,14 +5,22 @@ use List::Util qw( first ); > use YAML; > use C4::Context; > use Koha::Database; >+use Koha::Cache; > > sub get_yaml { >- my $yml_path = >- C4::Context->config('intranetdir') . '/admin/columns_settings.yml'; >- my $yaml = eval { YAML::LoadFile($yml_path) }; >- warn >-"ERROR: the yaml file for DT::ColumnsSettings is not correctly formated: $@" >- if $@; >+ my $yml_path = C4::Context->config('intranetdir') . '/admin/columns_settings.yml'; >+ >+ my $cache = Koha::Cache->get_instance(); >+ my $yaml = $cache->get_from_cache('ColumnsSettingsYaml'); >+ unless ($yaml) { >+ $yaml = eval { YAML::LoadFile($yml_path) }; >+ warn "############################# Not In Cache #############################" if $ENV{DEBUG}; >+ warn "ERROR: the yaml file for DT::ColumnsSettings is not correctly formated: $@" >+ if $@; >+ $cache->set_in_cache( 'ColumnsSettingsYaml', $yaml, { expiry => 3600 } ); >+ } else { >+ warn "############################# In Cache #############################" if $ENV{DEBUG}; >+ } > return $yaml; > } > >@@ -24,16 +32,14 @@ sub get_columns { > my $schema = Koha::Database->new->schema; > > my $rs = $schema->resultset('ColumnsSetting')->search( >- { >- module => $module, >+ { module => $module, > page => $page, > tablename => $tablename, > } > ); > > while ( my $c = $rs->next ) { >- my $column = first { $c->columnname eq $_->{columnname} } >- @{ $list->{modules}{ $c->module }{ $c->page }{ $c->tablename } }; >+ my $column = first { $c->columnname eq $_->{columnname} } @{ $list->{modules}{ $c->module }{ $c->page }{ $c->tablename } }; > $column->{is_hidden} = $c->is_hidden; > $column->{cannot_be_toggled} = $c->cannot_be_toggled; > } >@@ -48,8 +54,7 @@ sub get_modules { > my $rs = $schema->resultset('ColumnsSetting')->search; > > while ( my $c = $rs->next ) { >- my $column = first { $c->columnname eq $_->{columnname} } >- @{ $list->{modules}{ $c->module }{ $c->page }{ $c->tablename } }; >+ my $column = first { $c->columnname eq $_->{columnname} } @{ $list->{modules}{ $c->module }{ $c->page }{ $c->tablename } }; > $column->{is_hidden} = $c->is_hidden; > $column->{cannot_be_toggled} = $c->cannot_be_toggled; > } >@@ -68,11 +73,10 @@ sub update_columns { > $c->{cannot_be_toggled} //= 0; > > $schema->resultset('ColumnsSetting')->update_or_create( >- { >- module => $c->{module}, >- page => $c->{page}, >- tablename => $c->{tablename}, >- columnname => $c->{columnname}, >+ { module => $c->{module}, >+ page => $c->{page}, >+ tablename => $c->{tablename}, >+ columnname => $c->{columnname}, > is_hidden => $c->{is_hidden}, > cannot_be_toggled => $c->{cannot_be_toggled}, > } >-- >1.7.9.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 14207
:
39210
|
39211
|
39233
|
39514
|
40428
|
40457