Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

chi::driver::file(3pm) [debian man page]

CHI::Driver::File(3pm)					User Contributed Perl Documentation				    CHI::Driver::File(3pm)

NAME
CHI::Driver::File - File-based cache using one file per entry in a multi-level directory structure VERSION
version 0.54 SYNOPSIS
use CHI; my $cache = CHI->new( driver => 'File', root_dir => '/path/to/cache/root', depth => 3, max_key_length => 64 ); DESCRIPTION
This 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 OPTIONS
When using this driver, the following options can be passed to CHI->new() in addition to the CHI. root_dir The location in the filesystem that will hold the root of the cache. Defaults to a directory called 'chi-driver-file' under the OS default temp directory (e.g. '/tmp' on UNIX). This directory will be created as needed on the first cache set. depth The number of subdirectories deep to place cache files. Defaults to 2. This should be large enough that no leaf directory has more than a few hundred files. Each non-leaf directory contains up to 16 subdirectories (0-9, A-F). dir_create_mode Permissions mode to use when creating directories. Defaults to 0775. file_create_mode Permissions mode to use when creating files, modified by the current umask. Defaults to 0666. file_extension Extension to append to filename. Default is ".dat". METHODS
path_to_key ( $key ) Returns the full path to the cache file representing $key, whether or not that entry exists. Returns the empty list if a valid path cannot be computed, for example if the key is too long. path_to_namespace Returns the full path to the directory representing this cache's namespace, whether or not it has any entries. TEMPORARY FILE RENAME
By 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 ALSO
CHI AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 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. perl v5.14.2 2012-05-30 CHI::Driver::File(3pm)

Check Out this Related Man Page

CHI::Driver::FastMmap(3pm)				User Contributed Perl Documentation				CHI::Driver::FastMmap(3pm)

NAME
CHI::Driver::FastMmap - Persistent interprocess cache via mmap'ed files VERSION
version 0.54 SYNOPSIS
use CHI; my $cache = CHI->new( driver => 'FastMmap', root_dir => '/path/to/cache/root', cache_size => '1m' ); DESCRIPTION
This cache driver uses Cache::FastMmap to store data in an mmap'ed file. It is very fast, and can be used to share data between processes on a single host, though not between hosts. To support namespaces, this driver takes a directory parameter rather than a file, and creates one Cache::FastMMap file for each namespace. Because CHI handles serialization automatically, we pass the "raw_values" flag as 1; and to conform to the CHI API, we pass "unlink_on_exit" as 0, so that all cache files are permanent. REQUIREMENTS
You will need to install Cache::FastMmap from CPAN to use this driver. CONSTRUCTOR OPTIONS
root_dir Path to the directory that will contain the share files, one per namespace. Defaults to a directory called 'chi-driver-fastmmap' under the OS default temp directory (e.g. '/tmp' on UNIX). dir_create_mode Permissions mode to use when creating directories. Defaults to 0775. Any other constructor options not recognized by CHI are passed along to Cache::FastMmap->new. METHODS
fm_cache Returns a handle to the underlying Cache::FastMmap object. You can use this to call FastMmap-specific methods that are not supported by the general API, e.g. $self->fm_cache->get_and_set("key", sub { ... }); SEE ALSO
CHI AUTHOR
Jonathan Swartz <swartz@pobox.com> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 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. perl v5.14.2 2012-05-30 CHI::Driver::FastMmap(3pm)
Man Page