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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.