Bugzilla – Attachment 3564 Details for
Bug 6019
Using memoize_memcached to cache slow subroutines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Followup patch
0002-Bug-6019-Perf-enhancement-C4-SQLHelper.pm.patch (text/plain), 1.94 KB, created by
Chris Cormack
on 2011-03-31 02:36:47 UTC
(
hide
)
Description:
Followup patch
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2011-03-31 02:36:47 UTC
Size:
1.94 KB
patch
obsolete
>From ef5da8663477c3942e431a57eab64398323bcdae Mon Sep 17 00:00:00 2001 >From: Henri-Damien LAURENT <henridamien.laurent@biblibre.com> >Date: Mon, 12 Apr 2010 23:11:06 +0200 >Subject: [PATCH] Bug 6019 : Perf enhancement : C4/SQLHelper.pm > >Adding Memoize::Memcached and a hashref to store columns >--- > C4/SQLHelper.pm | 31 ++++++++++++++++++++++++++----- > 1 files changed, 26 insertions(+), 5 deletions(-) > >diff --git a/C4/SQLHelper.pm b/C4/SQLHelper.pm >index 060b78f..2738bb9 100644 >--- a/C4/SQLHelper.pm >+++ b/C4/SQLHelper.pm >@@ -27,6 +27,23 @@ use C4::Debug; > require Exporter; > use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS); > >+eval { >+ my $servers = C4::Context->config('memcached_servers'); >+ if ($servers) { >+ require Memoize::Memcached; >+ import Memoize::Memcached qw(memoize_memcached); >+ >+ my $memcached = { >+ servers => [ $servers ], >+ key_prefix => C4::Context->config('memcached_namespace') || 'koha', >+ }; >+ >+ memoize_memcached('_get_columns', memcached => $memcached, expire_time => 600000); #cache for 10 minutes >+ memoize_memcached('GetPrimaryKeys', memcached => $memcached, expire_time => 600000); #cache for 10 minutes >+ } >+}; >+ >+ > BEGIN { > # set the version for version checking > $VERSION = 0.5; >@@ -44,7 +61,7 @@ BEGIN { > } > > my $tablename; >-my $hash; >+my $hashref; > > =head1 NAME > >@@ -231,10 +248,14 @@ With > > sub _get_columns($) { > my ($tablename)=@_; >- my $dbh=C4::Context->dbh; >- my $sth=$dbh->prepare_cached(qq{SHOW COLUMNS FROM $tablename }); >- $sth->execute; >- my $columns= $sth->fetchall_hashref(qw(Field)); >+ unless (exists ($hashref->{$tablename})){ >+ my $dbh=C4::Context->dbh; >+ my $sth=$dbh->prepare_cached(qq{SHOW COLUMNS FROM $tablename }); >+ $sth->execute; >+ my $columns= $sth->fetchall_hashref(qw(Field)); >+ $hashref->{$tablename}=$columns; >+ } >+ return $hashref->{$tablename}; > } > > =head2 _filter_columns >-- >1.7.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 6019
:
3563
| 3564