Subject: | inconsistent results when trying to assign a value to a null key |
Date: | Tue, 3 Nov 2009 11:29:30 -0800 |
To: | "bug-Cache-Memcached-Fast [...] rt.cpan.org" <bug-Cache-Memcached-Fast [...] rt.cpan.org> |
From: | Zach Levow <zlevow [...] barracuda.com> |
Not sure if it is legal for the key to be null (\x00), but when it is, Cache::Memcached::Fast works first three times and then returns null for any request. We've fixed our bug that was generating null keys, but thought you might want to know. I don't know if this is a memcached problem, or if it occurs with the standard Cache::Memcached perl module.
Thanks,
Zach
Sample code to reproduce:
#!/usr/bin/perl -w
use strict;
use Cache::Memcached::Fast;
my $memd = undef;
$memd = new Cache::Memcached::Fast({
servers => [
'localhost:11211',
],
namespace => 'bcs:',
connect_timeout => 0.2,
io_timeout => 0.5,
close_on_error => 1,
compress_threshold => 100_000,
compress_ratio => 0.9,
compress_methods => [
\&IO::Compress::Gzip::gzip,
\&IO::Uncompress::Gunzip::gunzip
],
max_failures => 3,
failure_timeout => 2,
ketama_points => 150,
nowait => 1,
hash_namespace => 1,
serialize_methods => [ \&Storable::freeze, \&Storable::thaw ],
utf8 => 0,
max_size => 512 * 1024,
});
use Data::Dumper;
my $versions = $memd->server_versions;
print Dumper($versions);
for (1..5) {
my @set_results = $memd->set("a", 'aaaa');
my @get_results = $memd->get("a");
print Dumper(\@set_results, \@get_results);
@set_results = $memd->set("\x00", 'aaaa');
@get_results = $memd->get("\x00");
print Dumper(\@set_results, \@get_results);
}
Output of that code on my Debian box (Linux SERVERA 2.6.26-2-amd64 #1 SMP Wed Aug 19 22:33:18 UTC 2009 x86_64 GNU/Linux):
~/dev# /tmp/memcached_test.pl
$VAR1 = {
'localhost:11211' => '1.2.2'
};
$VAR1 = [
1
];
$VAR2 = [
'aaaa'
];
$VAR1 = [];
$VAR2 = [];
$VAR1 = [
1
];
$VAR2 = [
'aaaa'
];
$VAR1 = [];
$VAR2 = [];
$VAR1 = [
1
];
$VAR2 = [
'aaaa'
];
$VAR1 = [];
$VAR2 = [];
$VAR1 = [];
$VAR2 = [];
$VAR1 = [];
$VAR2 = [];
$VAR1 = [];
$VAR2 = [];
$VAR1 = [];
$VAR2 = [];
----------------------------------
Check out the Barracuda Spam & Virus Firewall - offering the fastest
virus & malware protection in the industry: www.barracudanetworks.com/spam