Bugzilla – Attachment 49730 Details for
Bug 16166
Improve L1 cache performance and safety
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16166: Try to add readability
Bug-16166-Try-to-add-readability.patch (text/plain), 2.59 KB, created by
Jonathan Druart
on 2016-03-31 10:57:10 UTC
(
hide
)
Description:
Bug 16166: Try to add readability
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-03-31 10:57:10 UTC
Size:
2.59 KB
patch
obsolete
>From d62d9ba627aa8dba59bd8b996490b7d790b5126b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 31 Mar 2016 11:56:11 +0100 >Subject: [PATCH] Bug 16166: Try to add readability > >--- > Koha/Cache.pm | 31 ++++++++++++++++--------------- > 1 file changed, 16 insertions(+), 15 deletions(-) > >diff --git a/Koha/Cache.pm b/Koha/Cache.pm >index 5c918d0..7013ac0 100644 >--- a/Koha/Cache.pm >+++ b/Koha/Cache.pm >@@ -281,14 +281,15 @@ sub set_in_cache { > $expiry //= $self->{timeout}; > my $set_sub = $self->{ref($self->{$cache}) . "_set"}; > >- my $flag = '-CF0'; # 0: scalar, 1: freezed data structure >+ my $flag = '-CF0'; # 0: scalar, 1: frozen data structure > # Set in L1 cache > if (ref($value)) { >- $value = freeze($value); >- $L1_cache{ $key } = [ (undef, $value) ]; >+ my $frozen= freeze($value); >+ $L1_cache{ $key } = { value => $value, frozen => $frozen }; >+ $value = $frozen; > $flag = '-CF1'; > } else { >- $L1_cache{ $key } = $value; >+ $L1_cache{ $key } = { value => $value }; > } > > $value .= $flag; >@@ -329,16 +330,15 @@ sub get_from_cache { > > # Return L1 cache value if exists > if ( exists $L1_cache{$key} ) { >- if (ref($L1_cache{$key})) { >+ if (ref($L1_cache{$key}{value})) { > if ($unsafe) { >- $L1_cache{$key}->[0] ||= thaw($L1_cache{$key}->[1]); >- return $L1_cache{$key}->[0]; >+ return $L1_cache{$key}->{value}; > } else { >- return thaw($L1_cache{$key}->[1]); >+ return thaw($L1_cache{$key}{frozen}); > } > } else { >- # No need to deep copy if it's a scalar >- return $L1_cache{$key}; >+ # No need to thaw if it's a scalar >+ return $L1_cache{$key}{value}; > } > } > >@@ -351,15 +351,16 @@ sub get_from_cache { > my $flag = substr($value, -4, 4, ''); > if ($flag eq '-CF0') { > # it's a scalar >- $L1_cache{$key} = $value; >+ $L1_cache{$key} = { value => $value }; > return $value; > } elsif ($flag eq '-CF1') { >- # it's a freezed data structure >+ # it's a frozen data structure >+ my $frozen = freeze($value); >+ $L1_cache{$key} = { value => $value, frozen => $frozen }; >+ return $value; > my $thawed; >- eval { $thawed = thaw($value); }; >+ eval { $thawed = thaw($frozen); }; > return if $@; >- $L1_cache{$key} = [ (undef, $value) ]; >- $L1_cache{$key}->[0] = $thawed if $unsafe; > return $thawed; > } > >-- >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 16166
:
49670
|
49729
|
49730
|
49739
|
50192
|
50708
|
50709
|
51763
|
51764
|
51765
|
52246
|
52265
|
52266
|
52509
|
52510
|
52863
|
52864