#!/usr/bin/perl

=pod

FreeBSD foo.com 6.2-STABLE FreeBSD 6.2-STABLE #0: Wed Mar 28 21:09:00 PDT 2007     foo@foo.com:/usr/obj/usr/src/sys/GENERIC  i386

memcached-1.2.3
p5-Cache-Memcached-1.24
libevent-1.3d       Provides an API to execute callback functions on certain ev

The output:

*****
Failed to write, and not due to blocking: Invalid argument
Use of uninitialized value in string eq at /usr/local/lib/perl5/site_perl/5.8.8/Cache/Memcached.pm line 494.
Failed to write, and not due to blocking: Invalid argument


ERROR: value not stored/retrieved correctly
****

The "Failed to write..." messages are from the server
The "Use of uninitialized..." are from Cache::Memcached

=cut

use warnings;
use strict;
use Cache::Memcached;

our $SOCK = "/tmp/memcached_test.sock";
our $PIDFILE = "/tmp/memcached_test.pid";

system("memcached -d -s $SOCK -P $PIDFILE -m 10 -v");

my $cache = Cache::Memcached->new(
	servers => [$SOCK]
);

$cache->set(foo => "bar");

my $val = $cache->get("foo");

if($val && $val eq "bar") {
	print "\n\nIT WORKS!\n\n"
}
else {
	print "\n\nERROR: value not stored/retrieved correctly\n\n";
}


system("kill `cat $PIDFILE`");
unlink $SOCK;
unlink $PIDFILE;
