From c55135b7e019922fb9eb3f3eb1a2d1f60fc2e9d0 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 16 Jun 2014 14:24:32 +0200 Subject: [PATCH] SL::DB::Unit::base_factor: Verwendung von $::request->cache() --- SL/DB/Unit.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/SL/DB/Unit.pm b/SL/DB/Unit.pm index b133d8f13..e8d260c67 100644 --- a/SL/DB/Unit.pm +++ b/SL/DB/Unit.pm @@ -39,11 +39,13 @@ sub convertible_units { sub base_factor { my ($self) = @_; - if (!defined $self->{__base_factor}) { - $self->{__base_factor} = !$self->base_unit || !$self->factor || ($self->name eq $self->base_unit) ? 1 : $self->factor * $self->base->base_factor; + my $cache = $::request->cache('base_factor'); + + if (!defined $cache->{$self->id}) { + $cache->{$self->id} = !$self->base_unit || !$self->factor || ($self->name eq $self->base_unit) ? 1 : $self->factor * $self->base->base_factor; } - return $self->{__base_factor}; + return $cache->{$self->id}; } sub convert_to { -- 2.20.1