/usr/share/perl5/CHI/Driver/RawMemory.pm is in libchi-perl 0.60-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | package CHI::Driver::RawMemory;
$CHI::Driver::RawMemory::VERSION = '0.60';
use Moo;
use strict;
use warnings;
extends 'CHI::Driver::Memory';
has 'serializer' => ( is => 'ro', init_arg => undef );
sub append {
my ( $self, $key, $new ) = @_;
return "append not yet supported in this driver";
}
1;
__END__
=pod
=head1 NAME
CHI::Driver::RawMemory - In-process memory cache that stores direct references
=head1 VERSION
version 0.60
=head1 SYNOPSIS
use CHI;
my $hash = {};
my $cache = CHI->new( driver => 'RawMemory', datastore => $hash );
my $cache = CHI->new( driver => 'RawMemory', global => 1 );
my $cache = CHI->new( driver => 'RawMemory', global => 0 );
=head1 DESCRIPTION
This is a subclass of L<CHI::Driver::Memory|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 I<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']!
=head1 CONSTRUCTOR OPTIONS
Same as L<CHI::Driver::Memory|CHI::Driver::Memory>.
=head1 SIZE AWARENESS
For the purpose of L<size-awareness|CHI/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 );
=head1 ACKNOWLEDGMENTS
Thanks to Yuval Kogman whose L<Cache::Ref> inspired me to do this.
=head1 SEE ALSO
L<CHI::Driver::Memory>, L<CHI>
=head1 AUTHOR
Jonathan Swartz <swartz@pobox.com>
=head1 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.
=cut
|