From 3ef245b21a397e5253ba1bda607a1510245d5c09 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Mon, 7 Apr 2014 16:38:31 +0800 Subject: Bug 987032: allow memcached to cache bugzilla configuration information r=dkl, a=glob --- Bugzilla/Status.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Bugzilla/Status.pm') diff --git a/Bugzilla/Status.pm b/Bugzilla/Status.pm index 964df9070..1f8862a36 100644 --- a/Bugzilla/Status.pm +++ b/Bugzilla/Status.pm @@ -108,11 +108,21 @@ sub _check_value { sub BUG_STATE_OPEN { my $dbh = Bugzilla->dbh; - my $cache = Bugzilla->request_cache; - $cache->{status_bug_state_open} ||= - $dbh->selectcol_arrayref('SELECT value FROM bug_status - WHERE is_open = 1'); - return @{ $cache->{status_bug_state_open} }; + my $request_cache = Bugzilla->request_cache; + my $cache_key = 'status_bug_state_open'; + return @{ $request_cache->{$cache_key} } + if exists $request_cache->{$cache_key}; + + my $rows = Bugzilla->memcached->get_config({ key => $cache_key }); + if (!$rows) { + $rows = $dbh->selectcol_arrayref( + 'SELECT value FROM bug_status WHERE is_open = 1' + ); + Bugzilla->memcached->set_config({ key => $cache_key, data => $rows }); + } + + $request_cache->{$cache_key} = $rows; + return @$rows; } # Tells you whether or not the argument is a valid "open" state. -- cgit v1.2.3-24-g4f1b