Lines 505-510
with this method.
Link Here
|
505 |
=cut |
505 |
=cut |
506 |
|
506 |
|
507 |
my $syspref_cache = Koha::Cache->get_instance(); |
507 |
my $syspref_cache = Koha::Cache->get_instance(); |
|
|
508 |
my %syspref_L1_cache; |
508 |
my $use_syspref_cache = 1; |
509 |
my $use_syspref_cache = 1; |
509 |
sub preference { |
510 |
sub preference { |
510 |
my $self = shift; |
511 |
my $self = shift; |
Lines 512-524
sub preference {
Link Here
|
512 |
|
513 |
|
513 |
$var = lc $var; |
514 |
$var = lc $var; |
514 |
|
515 |
|
|
|
516 |
# Return the value if the var has already been accessed |
517 |
if ($use_syspref_cache && exists $syspref_L1_cache{$var}) { |
518 |
return $syspref_L1_cache{$var}; |
519 |
} |
520 |
|
515 |
my $cached_var = $use_syspref_cache |
521 |
my $cached_var = $use_syspref_cache |
516 |
? $syspref_cache->get_from_cache("syspref_$var") |
522 |
? $syspref_cache->get_from_cache("syspref_$var") |
517 |
: undef; |
523 |
: undef; |
518 |
return $cached_var if defined $cached_var; |
524 |
return $cached_var if defined $cached_var; |
519 |
|
525 |
|
520 |
my $dbh = C4::Context->dbh or return 0; |
|
|
521 |
|
522 |
my $value; |
526 |
my $value; |
523 |
if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) { |
527 |
if ( defined $ENV{"OVERRIDE_SYSPREF_$var"} ) { |
524 |
$value = $ENV{"OVERRIDE_SYSPREF_$var"}; |
528 |
$value = $ENV{"OVERRIDE_SYSPREF_$var"}; |
Lines 528-534
sub preference {
Link Here
|
528 |
$value = $syspref ? $syspref->value() : undef; |
532 |
$value = $syspref ? $syspref->value() : undef; |
529 |
} |
533 |
} |
530 |
|
534 |
|
531 |
$syspref_cache->set_in_cache("syspref_$var", $value) if $use_syspref_cache; |
535 |
if ( $use_syspref_cache ) { |
|
|
536 |
$syspref_cache->set_in_cache("syspref_$var", $value); |
537 |
$syspref_L1_cache{$var} = $value; |
538 |
} |
532 |
return $value; |
539 |
return $value; |
533 |
} |
540 |
} |
534 |
|
541 |
|
Lines 581-587
will not be seen by this process.
Link Here
|
581 |
=cut |
588 |
=cut |
582 |
|
589 |
|
583 |
sub clear_syspref_cache { |
590 |
sub clear_syspref_cache { |
584 |
$syspref_cache->flush_all if $use_syspref_cache; |
591 |
return unless $use_syspref_cache; |
|
|
592 |
$syspref_cache->flush_all; |
593 |
clear_syspref_L1_cache() |
594 |
} |
595 |
|
596 |
sub clear_syspref_L1_cache { |
597 |
%syspref_L1_cache = (); |
585 |
} |
598 |
} |
586 |
|
599 |
|
587 |
=head2 set_preference |
600 |
=head2 set_preference |
Lines 632-639
sub set_preference {
Link Here
|
632 |
)->store(); |
645 |
)->store(); |
633 |
} |
646 |
} |
634 |
|
647 |
|
635 |
$syspref_cache->set_in_cache( "syspref_$variable", $value ) |
648 |
if ( $use_syspref_cache ) { |
636 |
if $use_syspref_cache; |
649 |
$syspref_cache->set_in_cache( "syspref_$variable", $value ); |
|
|
650 |
$syspref_L1_cache{$variable} = $value; |
651 |
} |
637 |
|
652 |
|
638 |
return $syspref; |
653 |
return $syspref; |
639 |
} |
654 |
} |
Lines 652-658
sub delete_preference {
Link Here
|
652 |
my ( $self, $var ) = @_; |
667 |
my ( $self, $var ) = @_; |
653 |
|
668 |
|
654 |
if ( Koha::Config::SysPrefs->find( $var )->delete ) { |
669 |
if ( Koha::Config::SysPrefs->find( $var )->delete ) { |
655 |
$syspref_cache->clear_from_cache("syspref_$var") if $use_syspref_cache; |
670 |
if ( $use_syspref_cache ) { |
|
|
671 |
$syspref_cache->clear_from_cache("syspref_$var"); |
672 |
delete $syspref_L1_cache{$var}; |
673 |
} |
674 |
|
656 |
return 1; |
675 |
return 1; |
657 |
} |
676 |
} |
658 |
return 0; |
677 |
return 0; |
659 |
- |
|
|