Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Memcache 'get' returns undef running under mod_perl

by graq (Curate)
on Nov 30, 2007 at 14:58 UTC ( [id://654127]=perlquestion: print w/replies, xml ) Need Help??

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 )=-

Replies are listed 'Best First'.
Re: Memcache 'get' returns undef running under mod_perl
by hsinclai (Deacon) on Nov 30, 2007 at 17:03 UTC
    Well something else must be up... your code works in my setup perfectly, I can even add new keys and get their values... this is also on Dead Rat (Centos 5:).

    Just to compare- I'm running memcached 1.2.2 compiled from source on x86_64, memcached user is "nobody" (not root).. my Cache::Memcached is version 1.24 from a CPAN install...

      Sorry the delay in replying. I was fairly sure it is a Perlism that is just beyond me.

      For completeness, it is running on 32 bit redhat 4 (2.6.17), memcache 1.2.2 and Cache::Memcached 1.24.

      Also; Apache 2.0, Perl 5.8.6, gcc 4.0.2, mod_perl 2

      -=( Graq )=-

Re: Memcache 'get' returns undef running under mod_perl (debug)
by tye (Sage) on Nov 30, 2007 at 16:51 UTC
    debug => 0,

    That seems the obvious place to start. :)

    - tye        

      Sadly, it does not seem very informative. Telling me that the value has been stored (which I know) and that the cache has been hit (which I know).

      Other than that, it is very silent

      -=( Graq )=-

        To continue with the simple and obvious suggestions (that you may have already tried), add "-vv" to your memcached command line. (I was also suspicious of your "-u root" as hsinclai highlighted but it'd also be interesting to learn of the mechanics of the failure.)

        - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://654127]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2024-04-19 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found