Bugzilla – Attachment 49187 Details for
Bug 16044
Define a L1 cache for all objects set in cache
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16044: Add deep cloning
Bug-16044-Add-deep-cloning.patch (text/plain), 1.36 KB, created by
Jonathan Druart
on 2016-03-15 16:43:21 UTC
(
hide
)
Description:
Bug 16044: Add deep cloning
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-03-15 16:43:21 UTC
Size:
1.36 KB
patch
obsolete
>From 1b2c07ced06b1f4cbb2c98b164eb88239617ab85 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 15 Mar 2016 16:17:32 +0000 >Subject: [PATCH] Bug 16044: Add deep cloning > >To avoid the cache to be modified unfortunately, the default behavior of >get_from_cache will be to deep copy if we are getting a structure. >If the item is a scalar, it's simply returned. >--- > Koha/Cache.pm | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > >diff --git a/Koha/Cache.pm b/Koha/Cache.pm >index 39a16d0..f389395 100644 >--- a/Koha/Cache.pm >+++ b/Koha/Cache.pm >@@ -38,6 +38,7 @@ The first, traditional OO interface provides the following functions: > use strict; > use warnings; > use Carp; >+use Clone qw( clone ); > use Module::Load::Conditional qw(can_load); > use Koha::Cache::Object; > >@@ -313,7 +314,12 @@ sub get_from_cache { > return unless ( $self->{$cache} && ref( $self->{$cache} ) =~ m/^Cache::/ ); > > # Return L1 cache value if exists >- return $L1_cache{$key} if exists $L1_cache{$key}; >+ if ( exists $L1_cache{$key} ) { >+ # No need to deep copy if it's a scalar: >+ return $L1_cache{$key} >+ unless ref $L1_cache{$key}; >+ return clone $L1_cache{$key}; >+ } > > my $get_sub = $self->{ref($self->{$cache}) . "_get"}; > return $get_sub ? $get_sub->($key) : $self->{$cache}->get($key); >-- >2.7.0
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 16044
:
48968
|
49179
|
49186
|
49187
|
49188
|
49239
|
49240
|
49490
|
49491
|
49492
|
49493
|
49494
|
49545
|
49546
|
49547
|
49548
|
49549
|
49555
|
49568
|
49647