IO::File::Cached - an caching file IO handle


IO-File-Cached documentation  | view source Contained in the IO-File-Cached distribution.

Index


NAME

Top

IO::File::Cached - an caching file IO handle

SYNOPSIS

Top

    use IO::File::Cached;

    # Open a file and read it line by line
    my $fh = IO::File::Cached->new(filename => $filename,
                                   cache => $cache);
    while (defined ($_ = $fh->read)) {
	print "Got line: $_\n";
    }
    $fh->close;

DESCRIPTION

Top

The IO::File::Cached module is a subclass of the IO::Scalar module that uses IO::File and Cache::Cache modules to access the contents of a file. The first time it is called for a particular file name it will load the file as normal using IO::File. The entire contents of the file will then be stored in the supplied cache object, such that later loads do not have to read from disk. One situation in which this can be useful is to cache files in memory across all processes in a mod_perl server.

METHODS

Top

new(filename => $filename[, cache => $cache] );

Creates a new IO::File::Cached object. If the cache parameter is supplied, this cache object will be used to load and store the file contents. At this time, instances of IO::File::Cached are read only. The object specified by the 'cache' parameter should be an instance of the Cache::Cache module.

AUTHORS

Top

Daniel Berrange <dan@berrange.com>

COPYRIGHT

Top

SEE ALSO

Top

perl(1), IO::Scalar, Cache::Cache, IO::File


IO-File-Cached documentation  | view source Contained in the IO-File-Cached distribution.