forked from GNUsocial/gnu-social
Cache IDs rather than profile objects
This commit is contained in:
parent
642b1044cc
commit
69fb79caae
@ -143,25 +143,28 @@ class User_group extends Managed_DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getMembers($offset=0, $limit=null) {
|
function getMembers($offset=0, $limit=null) {
|
||||||
|
$ids = null;
|
||||||
if (is_null($limit) || $offset + $limit > User_group::CACHE_WINDOW) {
|
if (is_null($limit) || $offset + $limit > User_group::CACHE_WINDOW) {
|
||||||
return $this->realGetMembers($offset,
|
$ids = $this->getMemberIDs($offset,
|
||||||
$limit);
|
$limit);
|
||||||
} else {
|
} else {
|
||||||
$key = sprintf('group:members:%d', $this->id);
|
$key = sprintf('group:members:%d', $this->id);
|
||||||
$window = self::cacheGet($key);
|
$window = self::cacheGet($key);
|
||||||
if ($window === false) {
|
if ($window === false) {
|
||||||
$members = $this->realGetMembers(0,
|
$window = $this->getMemberIDs(0,
|
||||||
User_group::CACHE_WINDOW);
|
User_group::CACHE_WINDOW);
|
||||||
$window = $members->fetchAll();
|
|
||||||
self::cacheSet($key, $window);
|
self::cacheSet($key, $window);
|
||||||
}
|
}
|
||||||
return new ArrayWrapper(array_slice($window,
|
|
||||||
$offset,
|
$ids = array_slice($window,
|
||||||
$limit));
|
$offset,
|
||||||
|
$limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Profile::multiGet('id', $ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
function realGetMembers($offset=0, $limit=null)
|
function getMemberIDs($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$gm = new Group_member();
|
$gm = new Group_member();
|
||||||
|
|
||||||
@ -184,9 +187,7 @@ class User_group extends Managed_DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$members = Profile::multiGet('id', $ids);
|
return $ids;
|
||||||
|
|
||||||
return $members;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user