nocte
Well-known member
see title.
The forum has a quite big gallery. Is there a way to optimize the cache rebuild?
I saw that just by chance. Did not check the random media cache rebuild yet.
Or maybe introduce a setting, that turns the the cache rebuild off? I assume that cache is only used for a widget.
Here's the code:
The forum has a quite big gallery. Is there a way to optimize the cache rebuild?
I saw that just by chance. Did not check the random media cache rebuild yet.
Or maybe introduce a setting, that turns the the cache rebuild off? I assume that cache is only used for a widget.
Here's the code:
PHP:
public function generateRandomAlbumCache()
{
$limit = 5;
$iterations = 100;
$maxId = (int)$this->db()->fetchOne('SELECT MAX(album_id) FROM xf_mg_album');
$albumIds = [];
while ($iterations > 0)
{
$iterations--;
$gt = mt_rand(0, max(0, $maxId - $limit));
$albumIds = array_merge($albumIds, $this->db()->fetchAllColumn('
SELECT album_id
FROM xf_mg_album
WHERE album_id > ?
LIMIT ?
', [$gt, $limit]));
}
return array_unique($albumIds);
}
public function getUserAlbumCount($userId)
{
return $this->db()->fetchOne("
SELECT COUNT(*)
FROM xf_mg_album
WHERE user_id = ?
AND album_state = 'visible'
", $userId);
}