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

(-)a/C4/Installer/PerlDependencies.pm (-5 lines)
Lines 267-277 our $PERL_DEPS = { Link Here
267
        'required' => '0',
267
        'required' => '0',
268
        'min_ver'  => '1.34'
268
        'min_ver'  => '1.34'
269
    },
269
    },
270
    'Cache::Memory' => {
271
        'usage'    => 'Caching',
272
        'required' => '0',
273
        'min_ver'  => '2.04'
274
    },
275
    'Net::LDAP::Filter' => {
270
    'Net::LDAP::Filter' => {
276
        'usage'    => 'LDAP Interface Feature',
271
        'usage'    => 'LDAP Interface Feature',
277
        'required' => '0',
272
        'required' => '0',
(-)a/Koha/Cache.pm (-37 lines)
Lines 103-117 sub new { Link Here
103
        $self->{'cache'} = $self->{'fastmmap_cache'};
103
        $self->{'cache'} = $self->{'fastmmap_cache'};
104
    }
104
    }
105
105
106
    # Unless memcache or fastmmap has already been picked, use memory_cache
107
    unless ( defined( $self->{'cache'} ) ) {
108
        if ( can_load( modules => { 'Cache::Memory' => undef } )
109
            && _initialize_memory($self) )
110
        {
111
                $self->{'cache'} = $self->{'memory_cache'};
112
        }
113
    }
114
115
    $ENV{DEBUG} && carp "Selected caching system: " . ($self->{'cache'} // 'none');
106
    $ENV{DEBUG} && carp "Selected caching system: " . ($self->{'cache'} // 'none');
116
107
117
    return
108
    return
Lines 177-209 sub _initialize_fastmmap { Link Here
177
    return $self;
168
    return $self;
178
}
169
}
179
170
180
sub _initialize_memory {
181
    my ($self) = @_;
182
183
    # Default cache time for memory is _always_ short unless it's specially
184
    # defined, to allow it to work reliably in a persistent environment.
185
    my $cache = Cache::Memory->new(
186
        'namespace'       => $self->{'namespace'},
187
        'default_expires' => "$self->{'timeout'} sec" || "10 sec",
188
    );
189
    $self->{'memory_cache'} = $cache;
190
    # Memory cache can't handle complex types for some reason, so we use its
191
    # freeze and thaw functions.
192
    $self->{ref($cache) . '_set'} = sub {
193
        my ($key, $val, $exp) = @_;
194
        # Refer to set_expiry in Cache::Entry for why we do this 'sec' thing.
195
        $exp = "$exp sec" if defined $exp;
196
        # Because we need to use freeze, it must be a reference type.
197
        $cache->freeze($key, [$val], $exp);
198
    };
199
    $self->{ref($cache) . '_get'} = sub {
200
        my $res = $cache->thaw(shift);
201
        return unless defined $res;
202
        return $res->[0];
203
    };
204
    return $self;
205
}
206
207
=head2 is_cache_active
171
=head2 is_cache_active
208
172
209
Routine that checks whether or not a default caching method is active on this
173
Routine that checks whether or not a default caching method is active on this
210
- 

Return to bug 21955