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;
}
Chris Wee - 2010-02-13T00:17:59 (permalink)
Was this review helpful to you?
Yes
No
Cache-FastMmap
(1.19)
Great module. Easy to use with no surprises. Very fast also.
Patrick LeBoutillier - 2007-09-19T06:36:33 (permalink)
3 out of 4 found this review helpful.
Was this review helpful to you?
Yes
No
Cache-FastMmap
(1.07)
Speedy!
gav - 2004-08-20T09:20:40 (permalink)
1 out of 3 found this review helpful.
Was this review helpful to you?
Yes
No
Cache-FastMmap
(1.01)
Fastest and most featureful cache module available.
jhoward - 2003-12-14T00:31:22 (permalink)
1 out of 2 found this review helpful.
Was this review helpful to you?
Yes
No

