From bba2bff3e15b5e5d2852822f6e060166fe0c51fe Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 19 Jun 2014 15:12:49 +0200 Subject: [PATCH] SL::DB::Part: Cachen von Objekten gefixt Teil 2 get_active_taxkey hat vorher ganz einfach nicht gecachet. --- SL/DB/Chart.pm | 11 +++++------ SL/DB/Manager/Chart.pm | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/SL/DB/Chart.pm b/SL/DB/Chart.pm index 7c50b43d3..40ac530d4 100644 --- a/SL/DB/Chart.pm +++ b/SL/DB/Chart.pm @@ -18,14 +18,13 @@ sub get_active_taxkey { $date ||= DateTime->today_local; my $cache = $::request->cache("get_active_taxkey")->{$date} //= {}; - if ($cache->{$self->id}) { - return $cache->{$self->id}; - } + return $cache->{$self->id} if $cache->{$self->id}; require SL::DB::TaxKey; - return SL::DB::Manager::TaxKey->get_all(query => [ and => [ chart_id => $self->id, - startdate => { le => $date } ] ], - sort_by => "startdate DESC")->[0]; + return $cache->{$self->id} = SL::DB::Manager::TaxKey->get_all( + query => [ and => [ chart_id => $self->id, + startdate => { le => $date } ] ], + sort_by => "startdate DESC")->[0]; } 1; diff --git a/SL/DB/Manager/Chart.pm b/SL/DB/Manager/Chart.pm index 81a65b5e8..f7728aef1 100644 --- a/SL/DB/Manager/Chart.pm +++ b/SL/DB/Manager/Chart.pm @@ -26,7 +26,7 @@ sub cache_taxkeys { my ($self, %params) = @_; my $date = $params{date} || DateTime->today; - my $cache = $::request->{cache}{chart}{$date} ||= {}; + my $cache = $::request->cache('::SL::DB::Chart::get_active_taxkey')->{$date} //= {}; require SL::DB::TaxKey; my $tks = SL::DB::Manager::TaxKey->get_all; -- 2.20.1