Next Lightweight Databases 64

Caching

        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;
        }
        tie @FILE, 'Tie::File', $myfile, memory => 200000000;


Next Copyright © 2003 M. J. Dominus