Commit 7248886ce9ea52f76ba279b5ac945fdd65603356
1 parent
e6068d99
Use caching for GroupUtil::_listGroupIDsForUserExpand
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5070 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
10 additions
and
2 deletions
lib/groups/GroupUtil.php
| @@ -232,9 +232,16 @@ class GroupUtil { | @@ -232,9 +232,16 @@ class GroupUtil { | ||
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | // {{{ _listGroupsIDsForUserExpand | 234 | // {{{ _listGroupsIDsForUserExpand |
| 235 | - function _listGroupIDsForUserExpand ($oUser, $aOptions = null) { | ||
| 236 | - global $default; | 235 | + function _listGroupIDsForUserExpand ($oUser) { |
| 237 | $iUserId = KTUtil::getId($oUser); | 236 | $iUserId = KTUtil::getId($oUser); |
| 237 | + global $default; | ||
| 238 | + $oCache = KTCache::getSingleton(); | ||
| 239 | + $group = "groupidsforuser"; | ||
| 240 | + list($bCached, $mCached) = $oCache->get($group, $oUser->getId()); | ||
| 241 | + if ($bCached) { | ||
| 242 | + $default->log->debug(sprintf("Using group cache for _listGroupIDsForUserExpand %d", $iUserId)); | ||
| 243 | + return $mCached; | ||
| 244 | + } | ||
| 238 | $aGroupArray = GroupUtil::_invertGroupArray(GroupUtil::buildGroupArray()); | 245 | $aGroupArray = GroupUtil::_invertGroupArray(GroupUtil::buildGroupArray()); |
| 239 | $aDirectGroups = GroupUtil::listGroupsForUser($oUser); | 246 | $aDirectGroups = GroupUtil::listGroupsForUser($oUser); |
| 240 | $sQuery = "SELECT group_id FROM $default->users_groups_table WHERE user_id = ?"; | 247 | $sQuery = "SELECT group_id FROM $default->users_groups_table WHERE user_id = ?"; |
| @@ -248,6 +255,7 @@ class GroupUtil { | @@ -248,6 +255,7 @@ class GroupUtil { | ||
| 248 | } | 255 | } |
| 249 | $aGroupIDs = array_unique($aGroupIDs); | 256 | $aGroupIDs = array_unique($aGroupIDs); |
| 250 | sort($aGroupIDs); | 257 | sort($aGroupIDs); |
| 258 | + $oCache->set($group, $oUser->getId(), $aGroupIDs); | ||
| 251 | return $aGroupIDs; | 259 | return $aGroupIDs; |
| 252 | } | 260 | } |
| 253 | // }}} | 261 | // }}} |