From: erickson Date: Tue, 1 Mar 2005 19:42:16 +0000 (+0000) Subject: altered the cache a little to allow for the servers to be passed in X-Git-Tag: osrf_rel_2_0_1~1742 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=00676500813a27ad5e310ef66d4d420834865574;p=OpenSRF.git altered the cache a little to allow for the servers to be passed in instead of reading them from a config file git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@130 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perlmods/OpenSRF/Utils/Cache.pm b/src/perlmods/OpenSRF/Utils/Cache.pm index cb54514..ec361d4 100644 --- a/src/perlmods/OpenSRF/Utils/Cache.pm +++ b/src/perlmods/OpenSRF/Utils/Cache.pm @@ -25,33 +25,27 @@ sub DESTROY {} my %caches; +# return a named cache if it exists sub current { - my ( $class, $c_type ) = @_; return undef unless $c_type; - return $caches{$c_type} if exists $caches{$c_type}; return $caches{$c_type} = $class->new( $c_type ); - } +# create a new named memcache object. sub new { - my( $class, $c_type ) = @_; - return undef unless $c_type; + my( $class, $cache_type, $servers ) = @_; + return undef unless $cache_type; - return $caches{$c_type} if exists $caches{$c_type}; + return $caches{$cache_type} if exists $caches{$cache_type}; $class = ref( $class ) || $class; - - my $config = OpenSRF::Utils::Config->current; - my $cache_servers = $config->mem_cache->$c_type; - - my $instance = Cache::Memcached->new( { servers => $cache_servers } ); - + my $instance = Cache::Memcached->new( { servers => $servers } ); + $caches{$cache_type} = $instance; return bless( $instance, $class ); - }