Koha/Koha/Caches.pm
Marcel de Rooy b4c66d5cc4 Bug 17935: Adjust some POD lines, fix a few typos
This patch does the following:

[1] Move some POD lines from Cache to Caches.
[2] Correct C4::Plugins to Koha::Plugins in POD line of Koha::Plugins
[3] POD Koha/AuthorisedValue.pm: lib_opac moved to opac_description
[4] The POD in Koha/Patron.pm uses head2 and head3 inconsistently.
    Ran s/^=head2/=head3/ on those lines (7 substitutions on 7 lines)
[5] Correct a copied POD line from reports/issues_stats.pl in
    reports/reserve_stats.pl.
[6] Correct a test description in t/db_dependent/Koha/Authorities.t.
    You should never delete the library :)
[7] Correct typo shouild in a comment of rebuild_zebra.pl

Test plan:
[1] Read the patch. Does it make sense?
[2] Run perldoc Koha/Cache.pm and Koha/Caches.pm
[3] Run t/db_dependent/Koha/Authorities.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2017-02-14 14:12:50 +00:00

67 lines
1.5 KiB
Perl

package Koha::Caches;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
=head1 NAME
Koha::Caches - Cache handling
=head1 SYNOPSIS
my $cache = Koha::Caches->get_instance();
=head1 DESCRIPTION
Description
=head1 CLASS METHODS
=cut
use Modern::Perl;
use Koha::Cache;
our $singleton_caches;
=head2 get_instance
This gets a shared instance of the cache, set up in a very default way. This is
the recommended way to fetch a cache object. If possible, it'll be
persistent across multiple instances.
=cut
sub get_instance {
my ($class, $subnamespace) = @_;
$subnamespace //= '';
$singleton_caches->{$subnamespace} = Koha::Cache->new({}, { subnamespace => $subnamespace } )
unless $singleton_caches->{$subnamespace};
return $singleton_caches->{$subnamespace};
}
=head2 flush_L1_caches
=cut
sub flush_L1_caches {
return unless $singleton_caches;
for my $cache ( values %$singleton_caches ) {
$cache->flush_L1_cache;
}
}
1;