Sophie

Sophie

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

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

<html><head><title>CHI::Driver::RawMemory</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='#SIZE_AWARENESS'>SIZE AWARENESS</a>
  <li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</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::RawMemory - In-process memory cache that stores direct references</p>

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

<pre>    use CHI;

    my $hash = {};
    my $cache = CHI-&#62;new( driver =&#62; &#39;RawMemory&#39;, datastore =&#62; $hash );

    my $cache = CHI-&#62;new( driver =&#62; &#39;RawMemory&#39;, global =&#62; 1 );</pre>

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

<p>This is a subclass of <a href="http://search.cpan.org/perldoc?CHI%3A%3ADriver%3A%3AMemory" class="podlinkpod"
>CHI::Driver::Memory</a> that stores references to data structures directly instead of serializing / deserializing. This makes the cache faster at getting and setting complex data structures, but unlike most drivers, modifications to the original data structure <i>will</i> affect the data structure stored in the cache, and vica versa. e.g.</p>

<pre>    my $cache = CHI-&#62;new( driver =&#62; &#39;Memory&#39;, global =&#62; 1 );
    my $lst = [&#39;foo&#39;];
    $cache-&#62;set(&#39;key&#39; =&#62; $lst);   # serializes $lst before storing
    $cache-&#62;get(&#39;key&#39;);   # returns [&#39;foo&#39;]
    $lst-&#62;[0] = &#39;bar&#39;;
    $cache-&#62;get(&#39;key&#39;);   # returns [&#39;foo&#39;]

    my $cache = CHI-&#62;new( driver =&#62; &#39;RawMemory&#39;, global =&#62; 1 );
    my $lst = [&#39;foo&#39;];
    $cache-&#62;set(&#39;key&#39; =&#62; $lst);   # stores $lst directly
    $cache-&#62;get(&#39;key&#39;);   # returns [&#39;foo&#39;]
    $lst-&#62;[0] = &#39;bar&#39;;
    $cache-&#62;get(&#39;key&#39;);   # returns [&#39;bar&#39;]!</pre>

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

<p>Same as <a href="http://search.cpan.org/perldoc?CHI%3A%3ADriver%3A%3AMemory" class="podlinkpod"
>CHI::Driver::Memory</a>.</p>

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

<p>For the purpose of <a href="http://search.cpan.org/perldoc?CHI#SIZE_AWARENESS" class="podlinkpod"
>size-awareness</a>, all items count as size 1 for this driver. (Because data structures are not serialized, there&#39;s no good way to determine their size.)</p>

<pre>    # Keep a maximum of 10 items in cache
    #
    my $cache = CHI-&#62;new( driver =&#62; &#39;RawMemory&#39;, datastore =&#62; {}, max_size =&#62; 10 );</pre>

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

<p><a href="http://search.cpan.org/perldoc?CHI%3A%3ADriver%3A%3AMemory" class="podlinkpod"
>CHI::Driver::Memory</a>, <a href="http://search.cpan.org/perldoc?CHI" class="podlinkpod"
>CHI</a></p>

<!-- end doc -->

</body></html>