From c8c70d5434e1844161a8b622cfe2e42e04b5fcf5 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 25 Dec 2018 09:11:38 +0100 Subject: Cache: Move CHI to deps Signed-off-by: Florian Pritz --- lib/App/ArchLinux/PackagerTools/Cache.pm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/App/ArchLinux/PackagerTools/Cache.pm b/lib/App/ArchLinux/PackagerTools/Cache.pm index c0b1aa6..6bfbd10 100644 --- a/lib/App/ArchLinux/PackagerTools/Cache.pm +++ b/lib/App/ArchLinux/PackagerTools/Cache.pm @@ -33,6 +33,12 @@ Returns a new instance. method new($class: $context, $deps = {}) { $deps->{config} //= App::ArchLinux::PackagerTools::Config->new($context); + my $config = $deps->{config}->get_config(); + + $deps->{CHI} //= CHI->new( + driver => 'File', + root_dir => $config->{cache}->{root_dir}, + ); return $class->new_no_defaults($context, $deps); } @@ -42,13 +48,6 @@ method new_no_defaults($class: $context, $deps = {}) { my $self = {}; bless $self, $class; $self->{deps} = $deps; - - my $config = $deps->{config}->get_config(); - - $self->{CHI} = CHI->new( - driver => 'File', - root_dir => $config->{cache}->{root_dir}, - ); $context->{$class} = $self; return $self; } @@ -68,7 +67,7 @@ timeout. =cut method compute($key, $timeout, $sub) { - return $self->{CHI}->compute($key, $timeout, $sub); + return $self->{deps}->{CHI}->compute($key, $timeout, $sub); } 1; -- cgit v1.2.3-24-g4f1b