From d4c35d4d1636a460e978e657b274faf5943dd444 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Mon, 14 May 2012 13:40:01 +0200 Subject: [PATCH] Bug 7248 follow-up (3): cache the cache handler Before this patch, a cache handler was opened everytime ->new() was called. With this patch, only the 1st call to ->new() create a handler --- Koha/Cache.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Koha/Cache.pm b/Koha/Cache.pm index ca409b7..bf1e977 100644 --- a/Koha/Cache.pm +++ b/Koha/Cache.pm @@ -49,12 +49,15 @@ use Carp; use base qw(Class::Accessor); +use vars qw($_cache_handler); + use Koha::Cache::Memcached; __PACKAGE__->mk_ro_accessors( qw( cache ) ); sub new { my $class = shift; + return $_cache_handler if $_cache_handler; # my $param = shift; my $cache; my $subclass; @@ -69,7 +72,8 @@ sub new { } ) or croak "Cannot create cache handle for memcache"; - return bless $class->SUPER::new({cache => $cache}), $subclass; + $_cache_handler = bless $class->SUPER::new({cache => $cache}), $subclass; + return $_cache_handler; } else { $ENV{DEBUG} && warn "No caching system"; return; -- 1.7.9.5