diff options
author | Bart Visscher <bartv@thisnet.nl> | 2014-02-21 22:52:48 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2014-02-21 23:07:35 +0100 |
commit | 6f4ecd32b37cc668ee0d59721c2451f349bb9290 (patch) | |
tree | 0e314e030fc1bada065e6c59c3945aead3ca9ceb /lib/private/group/manager.php | |
parent | 079d64ce750ac25a9562df75b663075304ab934a (diff) | |
download | nextcloud-server-6f4ecd32b37cc668ee0d59721c2451f349bb9290.tar.gz nextcloud-server-6f4ecd32b37cc668ee0d59721c2451f349bb9290.zip |
Add more caching in the group manager
Diffstat (limited to 'lib/private/group/manager.php')
-rw-r--r-- | lib/private/group/manager.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index 9b433b64fd4..451de0c0539 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -40,7 +40,12 @@ class Manager extends PublicEmitter { /** * @var \OC\Group\Group[] */ - private $cachedGroups; + private $cachedGroups = array(); + + /** + * @var \OC\Group\Group[] + */ + private $cachedUserGroups = array(); /** * @param \OC\User\Manager $userManager @@ -141,7 +146,7 @@ class Manager extends PublicEmitter { $offset -= count($groupIds); } foreach ($groupIds as $groupId) { - $groups[$groupId] = $this->getGroupObject($groupId); + $groups[$groupId] = $this->get($groupId); } if (!is_null($limit) and $limit <= 0) { return array_values($groups); @@ -155,13 +160,18 @@ class Manager extends PublicEmitter { * @return \OC\Group\Group[] */ public function getUserGroups($user) { + $uid = $user->getUID(); + if (isset($this->cachedUserGroups[$uid])) { + return $this->cachedUserGroups[$uid]; + } $groups = array(); foreach ($this->backends as $backend) { - $groupIds = $backend->getUserGroups($user->getUID()); + $groupIds = $backend->getUserGroups($uid); foreach ($groupIds as $groupId) { - $groups[$groupId] = $this->getGroupObject($groupId); + $groups[$groupId] = $this->get($groupId); } } - return array_values($groups); + $this->cachedUserGroups[$uid] = array_values($groups); + return $this->cachedUserGroups[$uid]; } } |