mget not working, but it's better than it was

This commit is contained in:
JT Smith 2009-09-24 22:31:19 -05:00
parent 180c207335
commit 65239eee4d
2 changed files with 13 additions and 6 deletions

View file

@ -136,11 +136,12 @@ sub mget {
foreach my $name (@{$names}) {
push @parsedNames, $self->parseKey($name);
}
$self->getMemcached->mget_into_hashref($self->getMemcached, \@parsedNames, my $result);
my %result;
$self->getMemcached->mget_into_hashref(\@parsedNames, \%result);
my @values = ();
foreach my $name (@{$names}) {
my $parsedName = shift @parsedNames;
push @values, ${$result->{$parsedName}};
foreach my $name (@parsedNames) {
next unless ref $result{$name};
push @values, ${$result{$name}};
}
return \@values;
}

View file

@ -29,7 +29,7 @@ my $session = WebGUI::Test->session;
#----------------------------------------------------------------------------
# Tests
plan tests => 3; # Increment this number for each test you create
plan tests => 7; # Increment this number for each test you create
#----------------------------------------------------------------------------
@ -37,7 +37,13 @@ my $cache = WebGUI::Cache->new($session);
isa_ok($cache, 'WebGUI::Cache');
is($cache->parseKey("andy"), $session->config->getFilename.":andy", "parseKey single key");
is($cache->parseKey(["andy","red"]), $session->config->getFilename.":andy:red", "parseKey composite key");
$cache->set("Shawshank","Prison");
is($cache->get("Shawshank"), "Prison", "set/get");
$cache->set(["andy", "dufresne"], "Prisoner");
is($cache->get(["andy", "dufresne"]), "Prisoner", "set/get composite");
my ($a, $b) = @{$cache->mget(["Shawshank",["andy", "dufresne"]])};
is($a, "Prison", "mget first value");
is($b, "Prisoner", "mget second value");