pod cleanup.
[p5sagit/p5-mst-13.2.git] / lib / Memoize / ExpireTest.pm
1
2 # This is just for testing expiration semantics.
3 # It's not actually a very good example of how to write
4 # an expiration module.  
5 #
6 # If you are looking for an example, I recommend that you look at the
7 # simple example in the Memoize::Expire documentation, or at the
8 # code for Memoize::Expire itself.
9 #
10 # If you have questions, I will be happy to answer them if you
11 # send them to mjd-perl/memoize+@plover.com.
12
13 package Memoize::ExpireTest;
14
15 my %cache;
16
17 sub TIEHASH {   
18   my ($pack) = @_;
19   bless \%cache => $pack;
20 }
21
22 sub EXISTS {
23   my ($cache, $key) = @_;
24   exists $cache->{$key} ? 1 : 0;
25 }
26
27 sub FETCH {
28   my ($cache, $key) = @_;
29   $cache->{$key};
30 }
31
32 sub STORE {
33   my ($cache, $key, $val) = @_;
34   $cache->{$key} = $val;
35 }
36
37 sub expire {
38   my ($key) = @_;
39   delete $cache{$key};
40 }
41
42 1;