Bugzilla – Attachment 9581 Details for
Bug 8089
Use Koha::Cache everywhere
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8089: Cache sysprefs using Koha::Cache
Bug-8089-Cache-sysprefs-using-KohaCache.patch (text/plain), 2.18 KB, created by
Jared Camins-Esakov
on 2012-05-15 11:42:53 UTC
(
hide
)
Description:
Bug 8089: Cache sysprefs using Koha::Cache
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-05-15 11:42:53 UTC
Size:
2.18 KB
patch
obsolete
>From c2fd9a7fc32e5e0a746b02f082fc781dff9cf69e Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Tue, 15 May 2012 07:14:01 -0400 >Subject: [PATCH] Bug 8089: Cache sysprefs using Koha::Cache >Content-Type: text/plain; charset="UTF-8" > >Cache sysprefs using Koha::Cache in a way that is safe even for >caching-related sysprefs. This lays the groundwork for removing >caching configuration from the httpd.conf and configuring it >using sysprefs. >--- > C4/Context.pm | 20 ++++++++++++++++++++ > 1 files changed, 20 insertions(+), 0 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index a451aa4..865c2a0 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -487,11 +487,20 @@ my %sysprefs; > sub preference { > my $self = shift; > my $var = lc(shift); # The system preference to return >+ my $cache; > > if (exists $sysprefs{$var}) { > return $sysprefs{$var}; > } > >+ if (Koha::Cache->is_cache_active()) { >+ $cache = Koha::Cache->new(); >+ if (defined $cache) { >+ $sysprefs{$var} = $cache->get_from_cache("syspref:$var"); >+ return $sysprefs{$var} if (defined $sysprefs{$var}); >+ } >+ } >+ > my $dbh = C4::Context->dbh or return 0; > > # Look up systempreferences.variable==$var >@@ -502,6 +511,9 @@ sub preference { > LIMIT 1 > END_SQL > $sysprefs{$var} = $dbh->selectrow_array( $sql, {}, $var ); >+ if (Koha::Cache->is_cache_active() && defined $cache) { >+ $cache->set_in_cache("syspref:$var"); >+ } > return $sysprefs{$var}; > } > >@@ -524,6 +536,10 @@ will not be seen by this process. > > sub clear_syspref_cache { > %sysprefs = (); >+ if (Koha::Cache->is_cache_active()) { >+ my $cache = Koha::Cache->new(); >+ $cache->flush_all() if defined $cache; # Sorry, this is unpleasant >+ } > } > > =head2 set_preference >@@ -554,6 +570,10 @@ sub set_preference { > " ); > > if($sth->execute( $var, $value )) { >+ if (Koha::Cache->is_cache_active()) { >+ my $cache = Koha::Cache->new(); >+ $cache->set_in_cache("syspref:$var", $value) if defined $cache; >+ } > $sysprefs{$var} = $value; > } > $sth->finish; >-- >1.7.2.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 8089
:
9577
|
9580
|
9581
|
9665
|
9666
|
9673
|
10166
|
10167
|
10168
|
11400
|
11401
|
11402
|
12077
|
12078
|
14765
|
14891
|
14893
|
16551