Bug 30920: (follow-up) Flush on delete

We missed the flush on delete triggers for the various caches introduced
here.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2023-03-10 15:26:45 +00:00 committed by Tomas Cohen Arazi
parent 7d9d795669
commit f716438555
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
5 changed files with 76 additions and 7 deletions

View file

@ -24,6 +24,8 @@ use Koha::Database;
use base qw(Koha::Object Koha::Object::Limit::Library); use base qw(Koha::Object Koha::Object::Limit::Library);
my $cache = Koha::Caches->get_instance();
=head1 NAME =head1 NAME
Koha::AuthorisedValue - Koha Authorised value Object class Koha::AuthorisedValue - Koha Authorised value Object class
@ -61,14 +63,26 @@ sub store {
$self = $self->SUPER::store; $self = $self->SUPER::store;
if ($flush) { if ($flush) {
my $cache = Koha::Caches->get_instance(); my $key = "AV_descriptions:".$self->category;
my $key = "AVDescriptions-".$self->category;
$cache->clear_from_cache($key); $cache->clear_from_cache($key);
} }
return $self; return $self;
} }
=head2 delete
AuthorisedValue specific C<delete> to clear relevant caches on delete.
=cut
sub delete {
my $self = shift @_;
my $key = "AV_descriptions:".$self->category;
$cache->clear_from_cache($key);
$self->SUPER::delete(@_);
}
=head3 opac_description =head3 opac_description
my $description = $av->opac_description(); my $description = $av->opac_description();

View file

@ -22,6 +22,8 @@ use Koha::Database;
use base qw(Koha::Object); use base qw(Koha::Object);
my $cache = Koha::Caches->get_instance();
=head1 NAME =head1 NAME
Koha::ClassSource - Koha Classfication Source Object class Koha::ClassSource - Koha Classfication Source Object class
@ -52,13 +54,24 @@ sub store {
$self = $self->SUPER::store; $self = $self->SUPER::store;
if ($flush) { if ($flush) {
my $cache = Koha::Caches->get_instance(); $cache->clear_from_cache('cn_sources:description');
$cache->clear_from_cache('cn)sources:description');
} }
return $self; return $self;
} }
=head2 delete
ClassSource specific C<delete> to clear relevant caches on delete.
=cut
sub delete {
my $self = shift @_;
$cache->clear_from_cache('cn_sources:description');
$self->SUPER::delete(@_);
}
=head3 _type =head3 _type
Returns name of corresponding DBIC resultset Returns name of corresponding DBIC resultset

View file

@ -27,6 +27,8 @@ use Koha::Localizations;
use base qw(Koha::Object Koha::Object::Limit::Library); use base qw(Koha::Object Koha::Object::Limit::Library);
my $cache = Koha::Caches->get_instance();
=head1 NAME =head1 NAME
Koha::ItemType - Koha Item type Object class Koha::ItemType - Koha Item type Object class
@ -59,7 +61,6 @@ sub store {
$self = $self->SUPER::store; $self = $self->SUPER::store;
if ($flush) { if ($flush) {
my $cache = Koha::Caches->get_instance();
my $key = "itemtype:description:en"; my $key = "itemtype:description:en";
$cache->clear_from_cache($key); $cache->clear_from_cache($key);
} }
@ -67,6 +68,18 @@ sub store {
return $self; return $self;
} }
=head2 delete
ItemType specific C<delete> to clear relevant caches on delete.
=cut
sub delete {
my $self = shift @_;
$cache->clear_from_cache('itemtype:description:en');
$self->SUPER::delete(@_);
}
=head3 image_location =head3 image_location
=cut =cut

View file

@ -29,6 +29,8 @@ use Koha::SMTP::Servers;
use base qw(Koha::Object); use base qw(Koha::Object);
my $cache = Koha::Caches->get_instance();
=head1 NAME =head1 NAME
Koha::Library - Koha Library Object class Koha::Library - Koha Library Object class
@ -59,13 +61,24 @@ sub store {
$self = $self->SUPER::store; $self = $self->SUPER::store;
if ($flush) { if ($flush) {
my $cache = Koha::Caches->get_instance();
$cache->clear_from_cache('libraries:name'); $cache->clear_from_cache('libraries:name');
} }
return $self; return $self;
} }
=head2 delete
Library specific C<delete> to clear relevant caches on delete.
=cut
sub delete {
my $self = shift @_;
$cache->clear_from_cache('libraries:name');
$self->SUPER::delete(@_);
}
=head3 stockrotationstages =head3 stockrotationstages
my $stages = Koha::Library->stockrotationstages; my $stages = Koha::Library->stockrotationstages;

View file

@ -21,6 +21,8 @@ use Koha::Database;
use base qw(Koha::Object); use base qw(Koha::Object);
my $cache = Koha::Caches->get_instance();
=head1 NAME =head1 NAME
Koha::Localization - Koha Localization type Object class Koha::Localization - Koha Localization type Object class
@ -42,7 +44,6 @@ sub store {
$self = $self->SUPER::store; $self = $self->SUPER::store;
if ($self->entity eq 'itemtypes') { if ($self->entity eq 'itemtypes') {
my $cache = Koha::Caches->get_instance();
my $key = "itemtype:description:".$self->lang; my $key = "itemtype:description:".$self->lang;
$cache->clear_from_cache($key); $cache->clear_from_cache($key);
} }
@ -50,6 +51,21 @@ sub store {
return $self; return $self;
} }
=head2 delete
Localization specific C<delete> to clear relevant caches on delete.
=cut
sub delete {
my $self = shift @_;
if ($self->entity eq 'itemtypes') {
my $key = "itemtype:description:".$self->lang;
$cache->clear_from_cache($key);
}
$self->SUPER::delete(@_);
}
sub _type { sub _type {
return 'Localization'; return 'Localization';
} }