package Singleton::MemCache; use strict; use warnings; { my $_cache; sub instance { $_cache ||= (shift)->new() } } sub new { my $class = shift; # see if we're enabled. eval { require Cache::Memcached; my $cache = Cache::Memcached->new({ servers => [ 'localhost:11211' ], }); return $cache; }; # we aren't. return bless {}, $class; } sub AUTOLOAD { wantarray ? () : undef } 1;