[Pkg-owncloud-commits] [owncloud] 17/153: Add more caching in the group manager
David Prévot
taffit at moszumanska.debian.org
Tue May 27 03:05:28 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 6f4ecd32b37cc668ee0d59721c2451f349bb9290
Author: Bart Visscher <bartv at thisnet.nl>
Date: Fri Feb 21 22:52:48 2014 +0100
Add more caching in the group manager
---
lib/private/group/manager.php | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index 9b433b6..451de0c 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];
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list