The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

FileCache::Appender - cache file handles opened for appending

VERSION

This document describes FileCache::Appender version 0.03

SYNOPSIS

    use FileCache::Appender;
    # returns cached file handle, or opens file for appending
    my $fh = FileCache::Appender->file($path);

DESCRIPTION

Caches file handles opened for appending. Helps to reduce number of I/O operations if you are appending data to many files.

METHODS

$class->new(%args)

Creates a new object. The following parameters are allowed:

max_open

maximum number of file handles to cache. If cache reaches this size, each time you requesting a new file handle, one of the existing will be removed from the cache.

mkpath

if directory in which file should be opened doesn't exist, create it

$self->file($path)

returns file handle for the file specified by $path. If file handle for the file is not in the cache, will open file for appending and cache file handle.

$self->clear

clear the cache

CAVEATS

If you need to append data to a big number of files, perhaps you should use a database.

Module does not perform any checks if file handle is still actual. If you closed file handle that you have got from cache, you still may get this handle next time you call file. If file was renamed, you still may get the handle pointing to it when requesting file using the old name.

BUGS

Please report any bugs or feature requests via GitHub bug tracker at http://github.com/trinitum/perl-FileCache-Appender/issues.

AUTHOR

Pavel Shaydo <zwon at cpan.org>

LICENSE AND COPYRIGHT

Copyright (C) 2014 Pavel Shaydo

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.