|
Lines 1-4
Link Here
|
| 1 |
package C4::Cache; |
1 |
package Koha::Cache; |
| 2 |
|
2 |
|
| 3 |
# Copyright 2009 Chris Cormack and The Koha Dev Team |
3 |
# Copyright 2009 Chris Cormack and The Koha Dev Team |
| 4 |
# |
4 |
# |
|
Lines 19-33
package C4::Cache;
Link Here
|
| 19 |
|
19 |
|
| 20 |
=head1 NAME |
20 |
=head1 NAME |
| 21 |
|
21 |
|
| 22 |
C4::Cache - Handling caching of html and Objects for Koha |
22 |
Koha::Cache - Handling caching of html and Objects for Koha |
| 23 |
|
23 |
|
| 24 |
=head1 SYNOPSIS |
24 |
=head1 SYNOPSIS |
| 25 |
|
25 |
|
| 26 |
use C4::Cache (cache_type => $cache_type, %params ); |
26 |
use Koha::Cache (cache_type => $cache_type, %params ); |
| 27 |
|
27 |
|
| 28 |
=head1 DESCRIPTION |
28 |
=head1 DESCRIPTION |
| 29 |
|
29 |
|
| 30 |
Base class for C4::Cache::X. Subclasses need to provide the following methods |
30 |
Base class for Koha::Cache::X. Subclasses need to provide the following methods |
| 31 |
|
31 |
|
| 32 |
B<_cache_handle ($params_hr)> - cache handle creator |
32 |
B<_cache_handle ($params_hr)> - cache handle creator |
| 33 |
|
33 |
|
|
Lines 49-67
use Carp;
Link Here
|
| 49 |
|
49 |
|
| 50 |
use base qw(Class::Accessor); |
50 |
use base qw(Class::Accessor); |
| 51 |
|
51 |
|
| 52 |
use C4::Cache::Memcached; |
52 |
use Koha::Cache::Memcached; |
| 53 |
|
53 |
|
| 54 |
__PACKAGE__->mk_ro_accessors( qw( cache ) ); |
54 |
__PACKAGE__->mk_ro_accessors( qw( cache ) ); |
| 55 |
|
55 |
|
| 56 |
sub new { |
56 |
sub new { |
| 57 |
my $class = shift; |
57 |
my $class = shift; |
| 58 |
my %param = @_; |
58 |
my $param = shift; |
| 59 |
|
59 |
my $cache_type = $param->{cache_type} || 'memcached'; |
| 60 |
my $cache_type = $param{cache_type} || 'memcached'; |
|
|
| 61 |
my $subclass = __PACKAGE__."::".ucfirst($cache_type); |
60 |
my $subclass = __PACKAGE__."::".ucfirst($cache_type); |
| 62 |
my $cache = $subclass->_cache_handle(\%param) |
61 |
my $cache = $subclass->_cache_handle($param) |
| 63 |
or croak "Cannot create cache handle for '$cache_type'"; |
62 |
or croak "Cannot create cache handle for '$cache_type'"; |
| 64 |
return bless $class->SUPER::new({cache => $cache}), $subclass; |
63 |
return bless $class->SUPER::new({cache => $cache}), $subclass; |
| 65 |
} |
64 |
} |
| 66 |
|
65 |
|
| 67 |
=head2 EXPORT |
66 |
=head2 EXPORT |
|
Lines 70-76
None by default.
Link Here
|
| 70 |
|
69 |
|
| 71 |
=head1 SEE ALSO |
70 |
=head1 SEE ALSO |
| 72 |
|
71 |
|
| 73 |
C4::Cache::Memcached |
72 |
Koha::Cache::Memcached |
| 74 |
|
73 |
|
| 75 |
=head1 AUTHOR |
74 |
=head1 AUTHOR |
| 76 |
|
75 |
|