|
NAMECHI::Driver::File - File-based cache using one file per entry in a multi-level directory structureVERSIONversion 0.60SYNOPSISuse CHI; my $cache = CHI->new( driver => 'File', root_dir => '/path/to/cache/root', depth => 3, max_key_length => 64 ); DESCRIPTIONThis cache driver stores data on the filesystem, so that it can be shared between processes on a single machine, or even on multiple machines if using NFS.Each item is stored in its own file. By default, during a set, a temporary file is created and then atomically renamed to the proper file. While not the most efficient, it eliminates the need for locking (with multiple overlapping sets, the last one "wins") and makes this cache usable in environments like NFS where locking might normally be undesirable. By default, the base filename is the key itself, with unsafe characters escaped similar to URL escaping. If the escaped key is larger than "max_key_length" (default 248 characters), it will be digested. You may want to lower "max_key_length" if you are storing a lot of items as long filenames can be more expensive to work with. The files are evenly distributed within a multi-level directory structure with a customizable "depth", to minimize the time needed to search for a given entry. CONSTRUCTOR OPTIONSWhen using this driver, the following options can be passed to CHI->new() in addition to the CHI.
METHODS
TEMPORARY FILE RENAMEBy default, during a set, a temporary file is created and then atomically renamed to the proper file. This eliminates the need for locking. You can subclass and override method generate_temporary_filename to either change the path of the temporary filename, or skip the temporary file and rename altogether by having it return undef.SEE ALSOCHIAUTHORJonathan Swartz <swartz@pobox.com>COPYRIGHT AND LICENSEThis software is copyright (c) 2012 by Jonathan Swartz.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |