diff options
Diffstat (limited to 'FS/FS/Conf.pm')
-rw-r--r-- | FS/FS/Conf.pm | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index c4e5af4e0..855c9f421 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1,7 +1,7 @@ package FS::Conf; -use vars qw($base_dir @config_items @base_items @card_types $DEBUG); use strict; +use vars qw($base_dir @config_items @base_items @card_types $DEBUG $conf_cache); use Carp; use IO::File; use File::Basename; @@ -134,9 +134,13 @@ sub _config { foreach my $a (@a) { $hashref->{agentnum} = $a; foreach my $l (@l) { - $hashref->{locale} = $l; - $cv = FS::Record::qsearchs('conf', $hashref); - return $cv if $cv; + my $key = join(':',$name, $a, $l); + if (! exists $conf_cache->{$key}){ + $hashref->{locale} = $l; + # $conf_cache is reset in FS::UID during myconnect, so the cache is reset per connection + $conf_cache->{$key} = FS::Record::qsearchs('conf', $hashref); + } + return $conf_cache->{$key} if $conf_cache->{$key}; } } return undef; @@ -362,6 +366,12 @@ sub set { $error = $new->insert; } + if (! $error) { + # clean the object cache + my $key = join(':',$name, $agentnum, $self->{locale}); + $conf_cache->{ $key } = $new; + } + die "error setting configuration value: $error \n" if $error; |