From: Evan Prodromou Date: Wed, 4 Jul 2012 18:38:06 +0000 (-0400) Subject: Cache IDs rather than profile objects X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=69fb79caaed1dee682959544123ed64bbf506213;p=quix0rs-gnu-social.git Cache IDs rather than profile objects --- diff --git a/classes/User_group.php b/classes/User_group.php index d343c622e3..f99feeb874 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -143,25 +143,28 @@ class User_group extends Managed_DataObject } function getMembers($offset=0, $limit=null) { + $ids = null; if (is_null($limit) || $offset + $limit > User_group::CACHE_WINDOW) { - return $this->realGetMembers($offset, - $limit); + $ids = $this->getMemberIDs($offset, + $limit); } else { $key = sprintf('group:members:%d', $this->id); $window = self::cacheGet($key); if ($window === false) { - $members = $this->realGetMembers(0, - User_group::CACHE_WINDOW); - $window = $members->fetchAll(); + $window = $this->getMemberIDs(0, + User_group::CACHE_WINDOW); self::cacheSet($key, $window); } - return new ArrayWrapper(array_slice($window, - $offset, - $limit)); + + $ids = array_slice($window, + $offset, + $limit); } + + return Profile::multiGet('id', $ids); } - function realGetMembers($offset=0, $limit=null) + function getMemberIDs($offset=0, $limit=null) { $gm = new Group_member(); @@ -184,9 +187,7 @@ class User_group extends Managed_DataObject } } - $members = Profile::multiGet('id', $ids); - - return $members; + return $ids; } /**