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/User.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Bugzilla/User.pm') diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 4f047ebdd..c37ab23f3 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -675,13 +675,23 @@ sub groups { FROM user_group_map WHERE user_id = ? AND isbless = 0}, undef, $self->id); - my $rows = $dbh->selectall_arrayref( - "SELECT DISTINCT grantor_id, member_id - FROM group_group_map - WHERE grant_type = " . GROUP_MEMBERSHIP); + my $cache_key = 'group_grant_type_' . GROUP_MEMBERSHIP; + my $membership_rows = Bugzilla->memcached->get_config({ + key => $cache_key, + }); + if (!$membership_rows) { + $membership_rows = $dbh->selectall_arrayref( + "SELECT DISTINCT grantor_id, member_id + FROM group_group_map + WHERE grant_type = " . GROUP_MEMBERSHIP); + Bugzilla->memcached->set_config({ + key => $cache_key, + data => $membership_rows, + }); + } my %group_membership; - foreach my $row (@$rows) { + foreach my $row (@$membership_rows) { my ($grantor_id, $member_id) = @$row; push (@{ $group_membership{$member_id} }, $grantor_id); } -- cgit v1.2.3-24-g4f1b