GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CHI::DRIVER::RAWMEMORY (3)

.ds Aq ’

NAME

CHI::Driver::RawMemory - In-process memory cache that stores direct references

CONTENTS

VERSION

version 0.58

SYNOPSIS



    use CHI;

    my $hash = {};
    my $cache = CHI->new( driver => RawMemory, datastore => $hash );

    my $cache = CHI->new( driver => RawMemory, global => 1 );



DESCRIPTION

This is a subclass of CHI::Driver::Memory 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 will affect the data structure stored in the cache, and vice versa. e.g.



    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]!



CONSTRUCTOR OPTIONS

Same as CHI::Driver::Memory.

SIZE AWARENESS

For the purpose of size-awareness, all items count as size 1 for this driver. (Because data structures are not serialized, there’s no good way to determine their size.)



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



ACKNOWLEDGMENTS

Thanks to Yuval Kogman whose Cache::Ref inspired me to do this.

SEE ALSO

CHI::Driver::Memory, CHI

AUTHOR

Jonathan Swartz <swartz@pobox.com>

COPYRIGHT AND LICENSE

This 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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CHI::DRIVER::RAWMEMORY (3) 2013-07-21

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.