From 7248886ce9ea52f76ba279b5ac945fdd65603356 Mon Sep 17 00:00:00 2001 From: nbm Date: Fri, 10 Mar 2006 09:23:15 +0000 Subject: [PATCH] Use caching for GroupUtil::_listGroupIDsForUserExpand --- lib/groups/GroupUtil.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/groups/GroupUtil.php b/lib/groups/GroupUtil.php index c4931b6..f6a0553 100644 --- a/lib/groups/GroupUtil.php +++ b/lib/groups/GroupUtil.php @@ -232,9 +232,16 @@ class GroupUtil { } // {{{ _listGroupsIDsForUserExpand - function _listGroupIDsForUserExpand ($oUser, $aOptions = null) { - global $default; + function _listGroupIDsForUserExpand ($oUser) { $iUserId = KTUtil::getId($oUser); + global $default; + $oCache = KTCache::getSingleton(); + $group = "groupidsforuser"; + list($bCached, $mCached) = $oCache->get($group, $oUser->getId()); + if ($bCached) { + $default->log->debug(sprintf("Using group cache for _listGroupIDsForUserExpand %d", $iUserId)); + return $mCached; + } $aGroupArray = GroupUtil::_invertGroupArray(GroupUtil::buildGroupArray()); $aDirectGroups = GroupUtil::listGroupsForUser($oUser); $sQuery = "SELECT group_id FROM $default->users_groups_table WHERE user_id = ?"; @@ -248,6 +255,7 @@ class GroupUtil { } $aGroupIDs = array_unique($aGroupIDs); sort($aGroupIDs); + $oCache->set($group, $oUser->getId(), $aGroupIDs); return $aGroupIDs; } // }}} -- libgit2 0.21.4