http://qs1969.pair.com?node_id=654127

graq has asked for the wisdom of the Perl Monks concerning the following question:

I have Cache::Memcache installed on Redhat. I have started the memcache process like so:

memcached -d -m1024 -l 127.0.0.1 -p 11211 -u root

Apache is configured like so:

PerlModule My::SSI <Files ~ "\.(s?html|xml)$"> RequestHeader unset If-Modified-Since RequestHeader unset If-None-Match ExpiresActive On ExpiresDefault "access plus 5 minutes" PerlOptions +SetupEnv PerlOutputFilterHandler My::SSI </Files>

In My::SSI I create various other objects and call methods on them. E.G. My::MemcacheTest->test

package My::MemcacheTest; # ... etc ... - let me know if this bit is important! sub test { my $memd = Cache::Memcached->new( servers => [ "127.0.0.1:11211" ], debug => 0, compress_threshold => 10_000, ); $memd->set('my_test','KISS'); my $simple_test = $memd->get('my_test') || 'This did not work'; print STDERR "Test Result = $simple_test\n"; }
#Outputs: 'Test Result = This did not work'

Elsewhere I have a simple script to read the memcached key, which works:

#!/usr/bun/perl use Cache::Memcached; my $memd = Cache::Memcached->new( servers => [ "127.0.0.1:11211" ], debug => 0, compress_threshold => 10_000, ); print "Memcached value is: ".$memd->get('my_test')." \n";
#Outputs: Memcache value is: KISS

I have tried various combinations of getting and setting values, the only one that doesn't work is 'get' through mod_perl

-=( Graq )=-