This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
document Git_Data
[perl5.git] / lib / Memoize / ExpireTest.pm
CommitLineData
9038e305 1package Memoize::ExpireTest;
a0cb3900 2
9038e305 3=head1 NAME
a0cb3900 4
9038e305
JH
5Memoize::ExpireTest - test for Memoize expiration semantics
6
7=head1 DESCRIPTION
8
899dc88a
JH
9This module is just for testing expiration semantics. It's not a very
10good example of how to write an expiration module.
9038e305
JH
11
12If you are looking for an example, I recommend that you look at the
13simple example in the Memoize::Expire documentation, or at the code
14for Memoize::Expire itself.
15
16If you have questions, I will be happy to answer them if you send them
899dc88a 17to mjd-perl-memoize+@plover.com.
9038e305
JH
18
19=cut
a0cb3900 20
899dc88a 21$VERSION = 0.65;
a0cb3900
JH
22my %cache;
23
24sub TIEHASH {
25 my ($pack) = @_;
26 bless \%cache => $pack;
27}
28
29sub EXISTS {
30 my ($cache, $key) = @_;
31 exists $cache->{$key} ? 1 : 0;
32}
33
34sub FETCH {
35 my ($cache, $key) = @_;
36 $cache->{$key};
37}
38
39sub STORE {
40 my ($cache, $key, $val) = @_;
41 $cache->{$key} = $val;
42}
43
44sub expire {
45 my ($key) = @_;
46 delete $cache{$key};
47}
48
491;