1e9dd878221209b3988e8658cc28fe42a4310353
[catagits/Catalyst-Plugin-Cache.git] / lib / Catalyst / Plugin / Cache / Backend / Memory.pm
1 #!/usr/bin/perl
2
3 package Catalyst::Plugin::Cache::Backend::Memory;
4 use Storable;
5
6 use strict;
7 use warnings;
8
9 use Storable qw/freeze thaw/;
10     
11 sub new { bless {}, shift }
12
13 sub get { ${thaw($_[0]{$_[1]}) || return} };
14
15 sub set { $_[0]{$_[1]} = freeze(\$_[2]) };
16
17 sub remove { delete $_[0]{$_[1]} };
18
19 __PACKAGE__;
20
21 __END__
22
23 =pod
24
25 =head1 NAME
26
27 Catalyst::Plugin::Cache::Backend::Memory - Stupid memory based caching backend.
28
29 =head1 SYNOPSIS
30
31     use Catalyst::Plugin::Cache::Backend::Memory;
32
33     my $m = Catalyst::Plugin::Cache::Backend::Memory->new;
34
35     $m->set( foo => "thing" );
36
37 =head1 DESCRIPTION
38
39 =cut
40
41