One instance of memcached server connection for all operations?

Grigory O. Ptashko trancer at
Fri Oct 21 02:58:31 PDT 2005

Hello, everybody!

I've just started to use Memcached and I have a question.
I'm using memcached within mod_perl2 environment.
I wrote a singleton perl class which is responsible for holding a
reference to the memcached server connection.
And everytime I want to use cache I say:

my $memd = MyCacheSingleton::get_instance()->get_cache_handler();
my $value = $memd->get("smth");
$memd->set("smth", 1);

which always returns the same connection because this class is a
singleton. And this statement might be called from different modules

Is it OK? Or do I have to connect to memcached server every time I
want to get smth from or set smth in the cache?
What about thread-safety?


More information about the memcached mailing list