I\'ve created a forum, and we\'re implementing an apc and memcache caching solution to save the database some work.
I started implementing the cache layer with keys like
One possible solution is not to paginate the cache of threads in a forum, but rather put the thread information in to Forum::getThreads|$iForumId
. Then in your PHP code only pull out the ones you want for that given page, e.g.
$page = 2;
$threads_per_page = 25;
$start_thread = $page * $threads_per_page;
// Pull threads from cache (assuming $cache class for memcache interface..)
$threads = $cache->get("Forum::getThreads|$iForumId");
// Only take the ones we need
for($i=$start_thread; $i<=$start_thread+$threads_per_page; $i++)
{
// Thread display logic here...
showThread($threads[$i]);
}
This means that you do have a bit more work to do pulling them out on each page, but now only have to worry about invalidating the cache in one place on update / addition of new thread.