Cache-FastMmap reviews

cpanratings
 

RSS | Module Info | Add a review of Cache-FastMmap

Cache-FastMmap (1.34) *****

Simple API and good documentation. I wrote the following sample as a test-drive. Nice.

#!/bin/perl -w
#
# Chris Wee, chris@weetopia.com
#
use strict;
use Cache::FastMmap;

# workers and parent agree upon a common filename
my $file = "/tmp/sharefile-$$-".time();

# parent's cache
my $Cache = Cache::FastMmap->new( share_file => $file, init_file => 1 );
$Cache->set($_,0) for (0 .. 9); # zero counters

for my $worker (1 .. 8) {

if (fork() == 0) {

# child

# Use own instance of the cache, not the parent's

my $kache = Cache::FastMmap->new( share_file => $file);

for (1 .. 10) {

my $interval = int(rand() * 10.0);

$kache->get_and_set($interval, sub { return ++$_[1]; }); # increment counter

sleep(1);

}

exit;

}
}

# parent

my $prev = -1;
while (1) {

my @counters = map { $Cache->get($_) } 0..9;

my $sum = unpack "%123i*" , pack( "i*", @counters);

exit if $prev == $sum;

print join(" ", @counters), " = $sum\n";

sleep(2);

$prev = $sum;
}

Cache-FastMmap (1.19) *****

Great module. Easy to use with no surprises. Very fast also.

Cache-FastMmap (1.07) *****

Speedy!

Cache-FastMmap (1.01) *****

Fastest and most featureful cache module available.