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

(-)a/C4/Biblio.pm (-8 / +10 lines)
Lines 1501-1515 sub GetAuthorisedValueDesc { Link Here
1501
1501
1502
    return q{} unless defined($value);
1502
    return q{} unless defined($value);
1503
1503
1504
    my $cache = Koha::Caches->get_instance();
1505
    my $cache_key;
1506
    if ( !$category ) {
1504
    if ( !$category ) {
1507
1505
1508
        return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};
1506
        return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};
1509
1507
1510
        #---- branch
1508
        #---- branch
1511
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
1509
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
1512
            $cache_key = "libraries:name";
1510
            my $cache     = Koha::Caches->get_instance();
1511
            my $cache_key = "libraries:name";
1513
            my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1512
            my $libraries = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1514
            if ( !$libraries ) {
1513
            if ( !$libraries ) {
1515
                $libraries = {
1514
                $libraries = {
Lines 1525-1534 sub GetAuthorisedValueDesc { Link Here
1525
1524
1526
        #---- itemtypes
1525
        #---- itemtypes
1527
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1526
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1528
            my $lang = C4::Languages::getlanguage;
1527
            my $cache = Koha::Caches->get_instance();
1528
            my $lang  = C4::Languages::getlanguage;
1529
            $lang //= 'en';
1529
            $lang //= 'en';
1530
            $cache_key = 'itemtype:description:' . $lang;
1530
            my $cache_key = 'itemtype:description:' . $lang;
1531
            my $itypes = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1531
            my $itypes    = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1532
            if ( !$itypes ) {
1532
            if ( !$itypes ) {
1533
                $itypes = { map { $_->itemtype => $_->translated_description } Koha::ItemTypes->search()->as_list };
1533
                $itypes = { map { $_->itemtype => $_->translated_description } Koha::ItemTypes->search()->as_list };
1534
                $cache->set_in_cache( $cache_key, $itypes );
1534
                $cache->set_in_cache( $cache_key, $itypes );
Lines 1537-1543 sub GetAuthorisedValueDesc { Link Here
1537
        }
1537
        }
1538
1538
1539
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
1539
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "cn_source" ) {
1540
            $cache_key = "cn_sources:description";
1540
            my $cache      = Koha::Caches->get_instance();
1541
            my $cache_key  = "cn_sources:description";
1541
            my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1542
            my $cn_sources = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1542
            if ( !$cn_sources ) {
1543
            if ( !$cn_sources ) {
1543
                $cn_sources = {
1544
                $cn_sources = {
Lines 1557-1563 sub GetAuthorisedValueDesc { Link Here
1557
1558
1558
    my $dbh = C4::Context->dbh;
1559
    my $dbh = C4::Context->dbh;
1559
    if ( $category ne "" ) {
1560
    if ( $category ne "" ) {
1560
        $cache_key = "AV_descriptions:" . $category;
1561
        my $cache           = Koha::Caches->get_instance('authorised-values');
1562
        my $cache_key       = "AV_descriptions:" . $category;
1561
        my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1563
        my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } );
1562
        if ( !$av_descriptions ) {
1564
        if ( !$av_descriptions ) {
1563
            $av_descriptions = {
1565
            $av_descriptions = {
(-)a/C4/Koha.pm (-2 / +2 lines)
Lines 515-521 sub GetAuthorisedValues { Link Here
515
    # Is this cached already?
515
    # Is this cached already?
516
    my $branch_limit = C4::Context::mybranch();
516
    my $branch_limit = C4::Context::mybranch();
517
    my $cache_key    = "AuthorisedValues-$category-$opac-$branch_limit";
517
    my $cache_key    = "AuthorisedValues-$category-$opac-$branch_limit";
518
    my $cache        = Koha::Caches->get_instance();
518
    my $cache        = Koha::Caches->get_instance('authorised-values');
519
    my $result       = $cache->get_from_cache($cache_key);
519
    my $result       = $cache->get_from_cache($cache_key);
520
    return $result if $result;
520
    return $result if $result;
521
521
Lines 560-566 sub GetAuthorisedValues { Link Here
560
    }
560
    }
561
    $sth->finish;
561
    $sth->finish;
562
562
563
    $cache->set_in_cache( $cache_key, \@results, { expiry => 5 } );
563
    $cache->set_in_cache( $cache_key, \@results );
564
    return \@results;
564
    return \@results;
565
}
565
}
566
566
(-)a/Koha/AuthorisedValue.pm (-2 / +6 lines)
Lines 30-36 use base qw(Koha::Object Koha::Object::Limit::Library); Link Here
30
use constant NUM_PATTERN    => q{^(-[1-9][0-9]*|0|[1-9][0-9]*)$};
30
use constant NUM_PATTERN    => q{^(-[1-9][0-9]*|0|[1-9][0-9]*)$};
31
use constant NUM_PATTERN_JS => q{(-[1-9][0-9]*|0|[1-9][0-9]*)};     # ^ and $ removed
31
use constant NUM_PATTERN_JS => q{(-[1-9][0-9]*|0|[1-9][0-9]*)};     # ^ and $ removed
32
32
33
my $cache = Koha::Caches->get_instance();
33
my $cache = Koha::Caches->get_instance('authorised-values');
34
34
35
=head1 NAME
35
=head1 NAME
36
36
Lines 70-75 sub store { Link Here
70
    $self = $self->SUPER::store;
70
    $self = $self->SUPER::store;
71
71
72
    if ($flush) {
72
    if ($flush) {
73
74
        # FIXME Clear the whole authorised-values instance
73
        my $key = "AV_descriptions:" . $self->category;
75
        my $key = "AV_descriptions:" . $self->category;
74
        $cache->clear_from_cache($key);
76
        $cache->clear_from_cache($key);
75
    }
77
    }
Lines 85-91 AuthorisedValue specific C<delete> to clear relevant caches on delete. Link Here
85
87
86
sub delete {
88
sub delete {
87
    my $self = shift @_;
89
    my $self = shift @_;
88
    my $key  = "AV_descriptions:" . $self->category;
90
91
    # FIXME Clear the whole authorised-values instance
92
    my $key = "AV_descriptions:" . $self->category;
89
    $cache->clear_from_cache($key);
93
    $cache->clear_from_cache($key);
90
    $self->SUPER::delete(@_);
94
    $self->SUPER::delete(@_);
91
}
95
}
(-)a/Koha/AuthorisedValues.pm (-3 / +2 lines)
Lines 55-61 sub find_description_by_code { Link Here
55
55
56
    # Is this cached already?
56
    # Is this cached already?
57
    my $cache_key = "AuthorisedValues-$category-values-$value-$opac-$default_to_blank";
57
    my $cache_key = "AuthorisedValues-$category-values-$value-$opac-$default_to_blank";
58
    my $cache     = Koha::Caches->get_instance();
58
    my $cache     = Koha::Caches->get_instance('authorised-values');
59
    my $result    = $cache->get_from_cache($cache_key);
59
    my $result    = $cache->get_from_cache($cache_key);
60
    return $result if $result;
60
    return $result if $result;
61
61
Lines 63-69 sub find_description_by_code { Link Here
63
63
64
    my $description = $av ? $opac ? $av->opac_description : $av->lib : $default_to_blank ? q{} : $value;
64
    my $description = $av ? $opac ? $av->opac_description : $av->lib : $default_to_blank ? q{} : $value;
65
65
66
    $cache->set_in_cache( $cache_key, $description, { expiry => 5 } );
66
    $cache->set_in_cache( $cache_key, $description );
67
67
68
    return $description;
68
    return $description;
69
}
69
}
70
- 

Return to bug 40554