Cache-BDB
view release on metacpan or search on metacpan
is($c->get(2),undef);
is($c->get(3),undef);
is($c->count, 0);
is($c->set(7, $hash1),1);
is($c->set(8, $hash2),1);
is($c->set(9, $array1),1);
is($c->set(10, $array2),1);
is($c->count, 4);
is($c->set(10, $hash2), 1);
is_deeply($c->get(10), $hash2);
undef $c;
is(undef, $c);
my $c2 = Cache::BDB->new(%options);
is_deeply($c2->get(7), $hash1);
is_deeply($c2->get(8), $hash2);
is_deeply($c2->get(9), $array1);
is_deeply($c2->get(10), $hash2);
is($c2->set('foo', 'bar'),1);
is($c2->get('foo'), 'bar');
my %h = (some => 'data', goes => 'here');
is($c2->set(100, \%h), 1);
is_deeply(\%h, $c2->get(100));
is($c2->add(100, \%h), 0, "Can't add, already exists");
is($c2->replace(100, \%h), 1, 'Can replace, already exists');
is($c2->add(101, \%h), 1, "Can add, doesn't exist yet");
is($c2->replace(102, \%h), 0, "Can't replace, doesn't exist");
is($c2->is_expired(6), 0, "expired? (should be by now)");
SKIP: {
eval { require Devel::Size };
skip "Devel::Size note available", 3 if $@;
ok($c2->size > 0);
ok($c2->clear());
ok($c2->size == 0);
}
SKIP: {
skip "db->compact not available", 2 unless
($BerkeleyDB::VERSION >= 0.29 && $BerkeleyDB::db_version >= 4.4);
# add a bunch of data
map { $c2->set($_, $_ * rand(int(20))) } (1 .. 12345);
my $h = $c2->get_bulk();
is(scalar(keys %$h), $c2->count);
# and see how big the file is
my $size_before = (stat(join('/', $options{cache_root},
'Cache::BDB::02.db')))[7];
my $count_before = $c2->count();
# clear it out
is($c2->clear(), $count_before);
# and check again.
my $size_after = (stat(join('/', $options{cache_root},
'Cache::BDB::02.db')))[7];
ok($size_before > $size_after);
}
( run in 2.720 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )