| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Egg::Model::Cache::Base; |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# $Id: Base.pm 293 2008-02-28 11:00:55Z lushe $ |
|
6
|
|
|
|
|
|
|
# |
|
7
|
1
|
|
|
1
|
|
502
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
29
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use base qw/ Egg::Model Egg::Component::Base /; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1327
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION= '0.01'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub setup_cache { |
|
16
|
|
|
|
|
|
|
my $class= shift; |
|
17
|
|
|
|
|
|
|
$class->can('cache') and die q{'cache' method has already been setup.}; |
|
18
|
|
|
|
|
|
|
my $pkg= shift || die q{I want cache module name.}; |
|
19
|
|
|
|
|
|
|
$pkg->require or die __PACKAGE__. "- $@"; |
|
20
|
|
|
|
|
|
|
no strict 'refs'; ## no critic. |
|
21
|
|
|
|
|
|
|
no warnings 'redefine'; |
|
22
|
|
|
|
|
|
|
*{"${class}::cache"}= sub { |
|
23
|
|
|
|
|
|
|
$_[0]->{cache_context} |
|
24
|
|
|
|
|
|
|
||= $pkg->new( wantarray ? %{$_[0]->config}: $_[0]->config ); |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
28
|
|
|
|
|
|
|
my $self= shift; |
|
29
|
|
|
|
|
|
|
my($method)= $AUTOLOAD=~m{([^\:]+)$}; |
|
30
|
|
|
|
|
|
|
$self->can('cache') || die q{'setup_cache' is not done.}; |
|
31
|
|
|
|
|
|
|
no strict 'refs'; ## no critic. |
|
32
|
|
|
|
|
|
|
no warnings 'redefine'; |
|
33
|
|
|
|
|
|
|
*{__PACKAGE__."::$method"}= sub { |
|
34
|
|
|
|
|
|
|
my $proto= shift; |
|
35
|
|
|
|
|
|
|
$proto->cache->$method(@_); |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
$self->$method(@_); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
sub DESTROY { } |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Egg::Model::Cache::Base - Base class to succeed to from CACHE controller. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
It is a base class to succeed to from the CACHE controller who generates it with |
|
52
|
|
|
|
|
|
|
L<Egg::Helper::Model::Cache>. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This module operates as Wrapper of the module passed to 'setup_cache' method. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Therefore, the method that can be used in the module set by 'setup_cache' method |
|
59
|
|
|
|
|
|
|
is different. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 setup_cache ([CACHE_MODULE]) |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
It is set up to use CACHE_MODULE. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__PACKAGE__->setup_cache('Cache::Memcached'); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 cache |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
It is a method of can use and when 'setup_cache' is done. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The object of the module passed by 'setup_cache' is returned. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<Egg::Release>, |
|
76
|
|
|
|
|
|
|
L<Egg::Model>, |
|
77
|
|
|
|
|
|
|
L<Egg::Model::Cache>, |
|
78
|
|
|
|
|
|
|
L<Egg::Helper::Model::Cache>, |
|
79
|
|
|
|
|
|
|
L<Egg::Component::Base>, |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
90
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.6 or, |
|
91
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|