Bugzilla – Attachment 53751 Details for
Bug 16769
Koha::Cache->set_in_cache calls need to be standardised
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16769: Uniformise calls to Koha::Cache->set_in_cache
Bug-16769-Uniformise-calls-to-KohaCache-setincache.patch (text/plain), 3.58 KB, created by
Marcel de Rooy
on 2016-07-27 14:17:47 UTC
(
hide
)
Description:
Bug 16769: Uniformise calls to Koha::Cache->set_in_cache
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-07-27 14:17:47 UTC
Size:
3.58 KB
patch
obsolete
>From eec88bf38928bc4d927370b28a014d9cdb7bbaa2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 18 Jun 2016 15:01:51 +0100 >Subject: [PATCH] Bug 16769: Uniformise calls to Koha::Cache->set_in_cache >Content-Type: text/plain; charset=utf-8 > >From the POD of Koha::Cache->set_in_cache: > # This is a bit of a hack to support the old API in case things still use it > >Let's remove this hack and update old calls. > >Test plan: >Look at the results of > git grep set_in_cache >and confirm that there are no more version of the old call (without >hashref as third param) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Cache.pm | 11 +++-------- > Koha/Calendar.pm | 2 +- > Koha/MetaSearcher.pm | 2 +- > t/Cache.t | 6 +++--- > 4 files changed, 8 insertions(+), 13 deletions(-) > >diff --git a/Koha/Cache.pm b/Koha/Cache.pm >index 0f85ed1..17babc8 100644 >--- a/Koha/Cache.pm >+++ b/Koha/Cache.pm >@@ -240,14 +240,9 @@ instance of C<Cache::*> and follow the same interface as L<Cache::Memcache>. > =cut > > sub set_in_cache { >- my ( $self, $key, $value, $options, $_cache) = @_; >- # This is a bit of a hack to support the old API in case things still use it >- if (defined $options && (ref($options) ne 'HASH')) { >- my $new_options; >- $new_options->{expiry} = $options; >- $new_options->{cache} = $_cache if defined $_cache; >- $options = $new_options; >- } >+ my ( $self, $key, $value, $options ) = @_; >+ >+ my $unsafe = $options->{unsafe} || 0; > > # the key mustn't contain whitespace (or control characters) for memcache > # but shouldn't be any harm in applying it globally. >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index 1321621..fe34b15 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -125,7 +125,7 @@ sub single_holidays { > $single_holidays->{$br} = \@ymd_arr; > } # br > $cache->set_in_cache( 'single_holidays', $single_holidays, >- 76800 ) #24 hrs ; >+ { expiry => 76800 } ) #24 hrs ; > } > my $holidays = ( $single_holidays->{$branchcode} ); > for my $hols (@$holidays ) { >diff --git a/Koha/MetaSearcher.pm b/Koha/MetaSearcher.pm >index e38b15d..1557ec1 100644 >--- a/Koha/MetaSearcher.pm >+++ b/Koha/MetaSearcher.pm >@@ -173,7 +173,7 @@ sub search { > hits => $result->{hits}, > num_fetched => $result->{num_fetched}, > num_hits => $result->{num_hits}, >- }, $resultset_expiry ); >+ }, { expiry => $resultset_expiry } ); > } > } > } >diff --git a/t/Cache.t b/t/Cache.t >index 1a25b77..1c34315 100644 >--- a/t/Cache.t >+++ b/t/Cache.t >@@ -53,16 +53,16 @@ SKIP: { > } > > # test expiry time in cache >- $cache->set_in_cache( "timeout", "I AM DATA", 1 ); # expiry time of 1 second >+ $cache->set_in_cache( "timeout", "I AM DATA", { expiry => 1 } ); # expiry time of 1 second > sleep 2; > $cache->flush_L1_cache(); > is( $cache->get_from_cache("timeout"), > undef, "fetching expired item from cache" ); > > # test fetching a valid, non expired, item from cache >- $cache->set_in_cache( "clear_me", "I AM MORE DATA", 1000 ) >+ $cache->set_in_cache( "clear_me", "I AM MORE DATA", { expiry => 1000 } ) > ; # overly large expiry time, clear below >- $cache->set_in_cache( "dont_clear_me", "I AM MORE DATA22", 1000 ) >+ $cache->set_in_cache( "dont_clear_me", "I AM MORE DATA22", { expiry => 1000 } ) > ; # overly large expiry time, clear below > is( > $cache->get_from_cache("clear_me"), >-- >1.7.10.4
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 16769
:
52512
|
53751
|
53752
|
53753
|
56013
|
56014
|
56015