<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->new( driver => 'RawMemory', datastore => $hash ); my $cache = CHI->new( driver => 'RawMemory', global => 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->new( driver => 'Memory', global => 1 ); my $lst = ['foo']; $cache->set('key' => $lst); # serializes $lst before storing $cache->get('key'); # returns ['foo'] $lst->[0] = 'bar'; $cache->get('key'); # returns ['foo'] my $cache = CHI->new( driver => 'RawMemory', global => 1 ); my $lst = ['foo']; $cache->set('key' => $lst); # stores $lst directly $cache->get('key'); # returns ['foo'] $lst->[0] = 'bar'; $cache->get('key'); # returns ['bar']!</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's no good way to determine their size.)</p> <pre> # Keep a maximum of 10 items in cache # my $cache = CHI->new( driver => 'RawMemory', datastore => {}, max_size => 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>