| File: | C4/Cache.pm |
| Coverage: | 64.5% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | package C4::Cache; | |||||
| 2 | ||||||
| 3 | # Copyright 2009 Chris Cormack and The Koha Dev Team | |||||
| 4 | # | |||||
| 5 | # This file is part of Koha. | |||||
| 6 | # | |||||
| 7 | # Koha is free software; you can redistribute it and/or modify it under the | |||||
| 8 | # terms of the GNU General Public License as published by the Free Software | |||||
| 9 | # Foundation; either version 2 of the License, or (at your option) any later | |||||
| 10 | # version. | |||||
| 11 | # | |||||
| 12 | # Koha is distributed in the hope that it will be useful, but WITHOUT ANY | |||||
| 13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |||||
| 14 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |||||
| 15 | # | |||||
| 16 | # You should have received a copy of the GNU General Public License along | |||||
| 17 | # with Koha; if not, write to the Free Software Foundation, Inc., | |||||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |||||
| 19 | ||||||
| 20 - 44 | =head1 NAME C4::Cache - Handling caching of html and Objects for Koha =head1 SYNOPSIS use C4::Cache (cache_type => $cache_type, %params ); =head1 DESCRIPTION Base class for C4::Cache::X. Subclasses need to provide the following methods B<_cache_handle ($params_hr)> - cache handle creator B<set_in_cache ($key, $value, $expiry)> B<get_from_cache ($key)> B<clear_from_cache ($key)> B<flush_all ()> =head1 FUNCTIONS =cut | |||||
| 45 | ||||||
| 46 | 6 6 6 | 82069 94 218 | use strict; | |||
| 47 | 6 6 6 | 91 69 245 | use warnings; | |||
| 48 | 6 6 6 | 81 61 696 | use Carp; | |||
| 49 | ||||||
| 50 | 6 6 6 | 123 54 729 | use base qw(Class::Accessor); | |||
| 51 | ||||||
| 52 | 6 6 6 | 72480 16 315 | use C4::Cache::Memcached; | |||
| 53 | ||||||
| 54 | __PACKAGE__->mk_ro_accessors( qw( cache ) ); | |||||
| 55 | ||||||
| 56 | sub new { | |||||
| 57 | 0 | my $class = shift; | ||||
| 58 | 0 | my %param = @_; | ||||
| 59 | ||||||
| 60 | 0 | my $cache_type = $param{cache_type} || 'memcached'; | ||||
| 61 | 0 | my $subclass = __PACKAGE__."::".ucfirst($cache_type); | ||||
| 62 | 0 | my $cache = $subclass->_cache_handle(\%param) | ||||
| 63 | or croak "Cannot create cache handle for '$cache_type'"; | |||||
| 64 | 0 | return bless $class->SUPER::new({cache => $cache}), $subclass; | ||||
| 65 | } | |||||
| 66 | ||||||
| 67 - 79 | =head2 EXPORT None by default. =head1 SEE ALSO C4::Cache::Memcached =head1 AUTHOR Chris Cormack, E<lt>chris@bigballofwax.co.nzE<gt> =cut | |||||
| 80 | ||||||
| 81 | 1; | |||||
| 82 | ||||||