File: Memory.pm

package info (click to toggle)
libcatalyst-plugin-cache-perl 0.12-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 264 kB
  • sloc: perl: 1,855; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 825 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl

package Catalyst::Plugin::Cache::Backend::Memory;
use Storable;

use strict;
use warnings;

use Storable qw/freeze thaw/;
    
sub new { bless {}, shift }

sub get { ${thaw($_[0]{$_[1]}) || return} };

sub set { $_[0]{$_[1]} = freeze(\$_[2]) };

sub remove { delete $_[0]{$_[1]} };

__PACKAGE__;

__END__

=pod

=head1 NAME

Catalyst::Plugin::Cache::Backend::Memory - Stupid memory based caching backend.

=head1 SYNOPSIS

    use Catalyst::Plugin::Cache::Backend::Memory;

    my $m = Catalyst::Plugin::Cache::Backend::Memory->new;

    $m->set( foo => "thing" );

=head1 DESCRIPTION

This backend uses L<Storable> to cache data in memory.

In combination with an engine like FastCGI/mod_perl/prefork which calls fork()
your cache will get async because child processes don't share cache in memory.

=cut