1 package Koha::Cache::Memcached;
3 # Copyright 2009 Chris Cormack and The Koha Dev Team
5 # This file is part of Koha.
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
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.
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.
26 use base qw(Koha::Cache);
31 my @servers = split /,/, $params->{'cache_servers'};
32 return Cache::Memcached->new(
34 namespace => $params->{'namespace'} || 'KOHA',
39 my ( $self, $key, $value, $expiry ) = @_;
40 croak "No key" unless $key;
41 $self->cache->set_debug;
43 if ( defined $expiry ) {
44 return $self->cache->set( $key, $value, $expiry );
47 return $self->cache->set( $key, $value );
52 my ( $self, $key ) = @_;
53 croak "No key" unless $key;
54 return $self->cache->get($key);
57 sub clear_from_cache {
58 my ( $self, $key ) = @_;
59 croak "No key" unless $key;
60 return $self->cache->delete($key);
65 return $self->cache->flush_all;
73 Koha::Cache::Memcached - memcached subclass of Koha::Cache