title: Caching paginated results, purging on update - how to solve?
body: <p>I've created a forum, and we're implementing an apc and memcache caching solution to save the database some work.</p>
  
  <p>I started implementing the cache layer with keys like "Categories::getAll", and if I had user-specific data, I'd append the keys with stuff like the user ID, so you'd get <code>"User::getFavoriteThreads|1471"</code>. When a  user added a new favorite thread, I'd delete the cache key, and it would recreate the entry.</p>
  
  <p><strong>However, and here comes the problem:</strong></p>
  
  <p>I wanted to cache the threads in a forum. Simple enough, "Forum::getThreads|$iForumId". But... With pagination, I'd have to split this into several cache entries, for example</p>
  
  <pre><code>"Forum::getThreads|$iForumId|$iLimit|$iOffset".
  </code></pre>
  
  <p>Which is alright, until someone posts a new thread in the forum. I will now have to delete all the keys under <code>"Forum::getThreads|$iForumId"</code>, no matter what the limit and offset is.</p>
  
  <p>What would be a good way of solving this problem? I'd really rather not loop through every possible limit and offset until I find something that doesn't match anymore.</p>
  
  <p>Thanks.</p>