Cache-Mmap
view release on metacpan or search on metacpan
}
my $head=pack("l6x$headsize",
magic,@$self{'buckets','bucketsize','pagesize'},$flags,filevers
);
sysseek $self->{_fh},SEEK_SET,0
or croak "Can't seek to beginning: $!";
syswrite($self->{_fh},$head,$headsize)==$headsize
or croak "Can't write file header: $!";
}
# mmap() isn't supposed to work on locked files, so unlock
$self->_unlock;
mmap($self->{_mmap}='',$size,$self->{_fh})
or do{
delete $self->{_mmap};
croak "Can't mmap $self->{_filename}: $!";
};
length($self->{_mmap}) eq $size
or do{
delete $self->{_mmap};
sub DESTROY{
my($self)=@_;
munmap($self->{_mmap}) if exists $self->{_mmap};
close $self->{_fh};
}
=item _lock($offset)
Lock the cache file. If $offset is zero, the file header is locked.
Otherwise, the bucket starting at $offset is locked.
XXX This also needs to create an internal lock if threading is enabled.
=cut
sub _lock{
my($self,$offset)=@_;
my $length=$offset ? $self->{bucketsize} : $headsize;
_lock_xs($self->{_fh},$offset,$length,1);
handles all the details of refreshing cache contents, and updating underlying
data, if necessary.
Changes between versions 0.10 and 0.11
Add 0.10's changes to this list
Changes between versions 0.09 and 0.10
Check perl's version number in a way that works on perl 5.10
Changes between versions 0.081 and 0.09
Behave correctly on systems which don't allow mmap()ing of locked files
Minor documentation improvements
INSTALLING
What you need to install this module:
Storable module
Test::More module (only used during testing)
How to install
perl Makefile.PL
make
( run in 1.303 second using v1.01-cache-2.11-cpan-49f99fa48dc )