Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > c575b3572b1a595b8b6ae0529951ea8a > files > 13

perl-CHI-0.44-3.fc14.noarch.rpm

<html><head><title>CHI::Driver::File</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
<link rel="stylesheet" type="text/css" title="pod_stylesheet" href="http://search.cpan.org/s/style.css">

</head>
<body class='pod'>
<!--
  generated by Pod::Simple::HTML v3.15,
  using Pod::Simple::PullParser v3.15,
  under Perl v5.012002 at Wed Mar  2 00:52:12 2011 GMT.

 If you want to change this HTML document, you probably shouldn't do that
   by changing it directly.  Instead, see about changing the calling options
   to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
   then reconverting this document from the Pod source.
   When in doubt, email the author of Pod::Simple::HTML for advice.
   See 'perldoc Pod::Simple::HTML' for more info.

-->

<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>

<div class='indexgroup'>
<ul   class='indexList indexList1'>
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
  <li class='indexItem indexItem1'><a href='#CONSTRUCTOR_OPTIONS'>CONSTRUCTOR OPTIONS</a>
  <li class='indexItem indexItem1'><a href='#METHODS'>METHODS</a>
  <li class='indexItem indexItem1'><a href='#TEMPORARY_FILE_RENAME'>TEMPORARY FILE RENAME</a>
</ul>
</div>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>

<p>CHI::Driver::File - File-based cache using one file per entry in a multi-level directory structure</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>

<pre>    use CHI;

    my $cache = CHI-&#62;new(
        driver         =&#62; &#39;File&#39;,
        root_dir       =&#62; &#39;/path/to/cache/root&#39;,
        depth          =&#62; 3,
        max_key_length =&#62; 64
    );</pre>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>

<p>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.</p>

<p>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 &#34;wins&#34;) and makes this cache usable in environments like NFS where locking might normally be undesirable.</p>

<p>By default, the base filename is the key itself, with unsafe characters escaped similar to URL escaping. If the escaped key is larger than <a href="#max_key_length" class="podlinkpod"
>&#34;max_key_length&#34;</a> (default 248 characters), it will be <a href="http://search.cpan.org/perldoc?CHI#key_digester" class="podlinkpod"
>digested</a>. You may want to lower <a href="#max_key_length" class="podlinkpod"
>&#34;max_key_length&#34;</a> if you are storing a lot of items as long filenames can be more expensive to work with.</p>

<p>The files are evenly distributed within a multi-level directory structure with a customizable <a href="#depth" class="podlinkpod"
>&#34;depth&#34;</a>, to minimize the time needed to search for a given entry.</p>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="CONSTRUCTOR_OPTIONS"
>CONSTRUCTOR OPTIONS</a></h1>

<p>When using this driver, the following options can be passed to CHI-&#62;new() in addition to the <a href="http://search.cpan.org/perldoc?general%20constructor%20options#constructor" class="podlinkpod"
>CHI</a>.</p>

<dl>
<dt><a name="root_dir"
>root_dir</a></dt>

<dd>
<p>The location in the filesystem that will hold the root of the cache. Defaults to a directory called &#39;chi-driver-file&#39; under the OS default temp directory (e.g. &#39;/tmp&#39; on UNIX). This directory will be created as needed on the first cache set.</p>

<dt><a name="depth"
>depth</a></dt>

<dd>
<p>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).</p>

<dt><a name="dir_create_mode"
>dir_create_mode</a></dt>

<dd>
<p>Permissions mode to use when creating directories. Defaults to 0775.</p>

<dt><a name="file_create_mode"
>file_create_mode</a></dt>

<dd>
<p>Permissions mode to use when creating files, modified by the current umask. Defaults to 0666.</p>

<dt><a name="file_extension"
>file_extension</a></dt>

<dd>
<p>Extension to append to filename. Default is &#34;.dat&#34;.</p>
</dd>
</dl>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="METHODS"
>METHODS</a></h1>

<dl>
<dt><a name="path_to_key_(_$key_)"
>path_to_key ( $key )</a></dt>

<dd>
<p>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.</p>

<dt><a name="path_to_namespace"
>path_to_namespace</a></dt>

<dd>
<p>Returns the full path to the directory representing this cache&#39;s namespace, whether or not it has any entries.</p>
</dd>
</dl>

<h1><a class='u' href='#___top' title='click to go to top of document'
name="TEMPORARY_FILE_RENAME"
>TEMPORARY FILE RENAME</a></h1>

<p>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 <i>generate_temporary_filename</i> to either change the path of the temporary filename, or skip the temporary file and rename altogether by having it return undef.</p>

<!-- end doc -->

</body></html>