| Next | Lightweight Databases | 64 |
Tie::File also maintains an internal read cache
If you try to read the same record twice, it comes from the read cache
sub _fetch {
my ($self, $n) = @_;
# check the record cache
{ my $cached = $self->{cache}->lookup($n);
return $cached if defined $cached;
}
...
$self->{cache}->insert($n, $rec)
if defined $rec && not $self->{flushing};
$rec;
}
This is supposed to cut down on I/O
You can limit the amount of memory used for the cache:
tie @FILE, 'Tie::File', $myfile, memory => 200000000;
Default: 2 MiB
| Next | ![]() |
Copyright © 2003 M. J. Dominus |