View | Details | Raw Unified | Return to bug 8092
Collapse All | Expand All

(-)a/Koha/Cache.pm (+4 lines)
Lines 92-97 sub set_in_cache { Link Here
92
    croak "No key" unless $key;
92
    croak "No key" unless $key;
93
    $ENV{DEBUG} && warn "set_in_cache for $key";
93
    $ENV{DEBUG} && warn "set_in_cache for $key";
94
94
95
    return unless $self->{cache};
95
    return unless $self->{have_chi};
96
    return unless $self->{have_chi};
96
97
97
    if ( defined $expiry ) {
98
    if ( defined $expiry ) {
Lines 106-111 sub get_from_cache { Link Here
106
    my ( $self, $key ) = @_;
107
    my ( $self, $key ) = @_;
107
    croak "No key" unless $key;
108
    croak "No key" unless $key;
108
    $ENV{DEBUG} && warn "get_from_cache for $key";
109
    $ENV{DEBUG} && warn "get_from_cache for $key";
110
    return unless $self->{cache};
109
    return unless $self->{have_chi};
111
    return unless $self->{have_chi};
110
    return $self->{cache}->get($key);
112
    return $self->{cache}->get($key);
111
}
113
}
Lines 113-124 sub get_from_cache { Link Here
113
sub clear_from_cache {
115
sub clear_from_cache {
114
    my ( $self, $key ) = @_;
116
    my ( $self, $key ) = @_;
115
    croak "No key" unless $key;
117
    croak "No key" unless $key;
118
    return unless $self->{cache};
116
    return unless $self->{have_chi};
119
    return unless $self->{have_chi};
117
    return $self->{cache}->remove($key);
120
    return $self->{cache}->remove($key);
118
}
121
}
119
122
120
sub flush_all {
123
sub flush_all {
121
    my $self = shift;
124
    my $self = shift;
125
    return unless $self->{cache};
122
    return unless $self->{have_chi};
126
    return unless $self->{have_chi};
123
    return $self->{cache}->clear();
127
    return $self->{cache}->clear();
124
}
128
}
(-)a/Koha/Cache/Fastmmap.pm (-7 / +11 lines)
Lines 20-38 package Koha::Cache::Fastmmap; Link Here
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
use Carp;
22
use Carp;
23
use CHI;
23
use Module::Load::Conditional qw(can_load);
24
24
25
use base qw(Koha::Cache);
25
use base qw(Koha::Cache);
26
26
27
sub _cache_handle {
27
sub _cache_handle {
28
    my $class  = shift;
28
    my $class  = shift;
29
    my $params = shift;
29
    my $params = shift;
30
    return CHI->new(
30
    if ( can_load( modules => { CHI => undef } ) ) {
31
        driver     => 'FastMmap',
31
        return CHI->new(
32
        namespace  => $params->{'namespace'} || 'koha',
32
            driver     => 'FastMmap',
33
        expire_in  => 600,
33
            namespace  => $params->{'namespace'} || 'koha',
34
        cache_size => $params->{'cachesize'} || '1m',
34
            expire_in  => 600,
35
    );
35
            cache_size => $params->{'cachesize'} || '1m',
36
        );
37
    } else {
38
        return undef;
39
    }
36
}
40
}
37
41
38
1;
42
1;
(-)a/Koha/Cache/Memory.pm (-9 / +12 lines)
Lines 20-39 package Koha::Cache::Memory; Link Here
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
use Carp;
22
use Carp;
23
use CHI;
23
use Module::Load::Conditional qw(can_load);
24
24
25
use base qw(Koha::Cache);
25
use base qw(Koha::Cache);
26
26
27
sub _cache_handle {
27
sub _cache_handle {
28
    my $class  = shift;
28
    my $class  = shift;
29
    my $params = shift;
29
    my $params = shift;
30
    return CHI->new(
30
    if ( can_load( modules => { CHI => undef } ) ) {
31
        driver    => 'Memory',
31
        return CHI->new(
32
        namespace => $params->{'namespace'} || 'koha',
32
            driver    => 'Memory',
33
        expire_in => 600,
33
            namespace => $params->{'namespace'} || 'koha',
34
        max_size  => $params->{'max_size'} || 8192 * 1024,
34
            expire_in => 600,
35
        global    => 1,
35
            max_size  => $params->{'max_size'} || 8192 * 1024,
36
    );
36
            global    => 1,
37
        );
38
    } else {
39
        return undef;
40
    }
37
}
41
}
38
42
39
1;
43
1;
40
- 

Return to bug 8092