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

(-)a/C4/Koha.pm (-2 / +13 lines)
Lines 1008-1013 C<$opac> If set to a true value, displays OPAC descriptions rather than normal o Link Here
1008
1008
1009
=cut
1009
=cut
1010
1010
1011
sub _AddSelectedAuthVal {
1012
    my ( $authorised_values, $selected ) = @_;
1013
    foreach my $data ( @$authorised_values ) {
1014
        $data->{selected} = $selected eq $data->{authorised_value} ? 1 : 0;
1015
    }
1016
}
1017
1011
sub GetAuthorisedValues {
1018
sub GetAuthorisedValues {
1012
    my ( $category, $opac ) = @_;
1019
    my ( $category, $opac ) = @_;
1013
1020
Lines 1019-1025 sub GetAuthorisedValues { Link Here
1019
      "AuthorisedValues-$category-$opac-$branch_limit";
1026
      "AuthorisedValues-$category-$opac-$branch_limit";
1020
    my $cache  = Koha::Cache->get_instance();
1027
    my $cache  = Koha::Cache->get_instance();
1021
    my $result = $cache->get_from_cache($cache_key);
1028
    my $result = $cache->get_from_cache($cache_key);
1022
    return $result if $result;
1029
    if ($result) {
1030
        _AddSelectedAuthVal( $result, $selected ) if defined $selected;
1031
        return $result;
1032
    }
1023
1033
1024
    my @results;
1034
    my @results;
1025
    my $dbh      = C4::Context->dbh;
1035
    my $dbh      = C4::Context->dbh;
Lines 1060-1066 sub GetAuthorisedValues { Link Here
1060
    }
1070
    }
1061
    $sth->finish;
1071
    $sth->finish;
1062
1072
1063
    $cache->set_in_cache( $cache_key, \@results, { deepcopy => 1, expiry => 5 } );
1073
    $cache->set_in_cache( $cache_key, \@results );
1074
    _AddSelectedAuthVal( \@results, $selected );
1064
    return \@results;
1075
    return \@results;
1065
}
1076
}
1066
1077
(-)a/Koha/Cache.pm (+20 lines)
Lines 41-46 use Carp; Link Here
41
use Clone qw( clone );
41
use Clone qw( clone );
42
use Module::Load::Conditional qw(can_load);
42
use Module::Load::Conditional qw(can_load);
43
use Koha::Cache::Object;
43
use Koha::Cache::Object;
44
use Time::HiRes qw(time);
44
45
45
use base qw(Class::Accessor);
46
use base qw(Class::Accessor);
46
47
Lines 48-53 __PACKAGE__->mk_ro_accessors( Link Here
48
    qw( cache memcached_cache fastmmap_cache memory_cache ));
49
    qw( cache memcached_cache fastmmap_cache memory_cache ));
49
50
50
our %L1_cache;
51
our %L1_cache;
52
our $L1_cache_time;
51
53
52
=head2 get_instance
54
=head2 get_instance
53
55
Lines 131-136 sub new { Link Here
131
      $class;
133
      $class;
132
}
134
}
133
135
136
sub flush_L1_if_needed {
137
    my ($self) = @_;
138
139
    if ( $self->{cache} ) {
140
        if ( $L1_cache_time ) {
141
            my $upstream_cache_mtime = $self->{cache}->get('upstream_cache_mtime');
142
143
            if ( $upstream_cache_mtime && $upstream_cache_mtime > $L1_cache_time ) {
144
                $self->flush_L1_cache();
145
            }
146
        }
147
148
        $L1_cache_time = time();
149
    }
150
}
151
134
sub _initialize_memcached {
152
sub _initialize_memcached {
135
    my ($self) = @_;
153
    my ($self) = @_;
136
    my @servers =
154
    my @servers =
Lines 288-293 sub set_in_cache { Link Here
288
    # Set in L1 cache
306
    # Set in L1 cache
289
    $L1_cache{ $key } = $value;
307
    $L1_cache{ $key } = $value;
290
308
309
    $self->{$cache}->set( 'upstream_cache_mtime', time() );
310
291
    # We consider an expiry of 0 to be inifinite
311
    # We consider an expiry of 0 to be inifinite
292
    if ( $expiry ) {
312
    if ( $expiry ) {
293
        return $set_sub
313
        return $set_sub
(-)a/debian/templates/plack.psgi (-1 / +1 lines)
Lines 44-50 use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise Link Here
44
    *CGI::new = sub {
44
    *CGI::new = sub {
45
        my $q = $old_new->( @_ );
45
        my $q = $old_new->( @_ );
46
        $CGI::PARAM_UTF8 = 1;
46
        $CGI::PARAM_UTF8 = 1;
47
        Koha::Cache->flush_L1_cache();
47
        Koha::Cache->flush_L1_if_needed();
48
        return $q;
48
        return $q;
49
    };
49
    };
50
}
50
}
(-)a/misc/plack/koha.psgi (-2 / +1 lines)
Lines 12-18 use CGI qw(-utf8 ); # we will lose -utf8 under plack Link Here
12
    *CGI::new = sub {
12
    *CGI::new = sub {
13
        my $q = $old_new->( @_ );
13
        my $q = $old_new->( @_ );
14
        $CGI::PARAM_UTF8 = 1;
14
        $CGI::PARAM_UTF8 = 1;
15
        Koha::Cache->flush_L1_cache();
15
        Koha::Cache->flush_L1_if_needed();
16
        return $q;
16
        return $q;
17
    };
17
    };
18
}
18
}
19
- 

Return to bug 16140