<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div style="WORD-WRAP: break-word">
<div><span style="WHITE-SPACE: pre"></span>That just doesn't sound expensive to me. If you have each comment in its own cache entry, and a cache entry for the list, you can replace the components or the list independently, and then do one cache query to get the list, to convert the id list to a comment list. If the list, or any comments are missing, you'll, of course, need to fetch those.
</div>
<div><br> </div>
<div><span style="WHITE-SPACE: pre"></span>After that, your filter op can happen on the client:</div>
<div><br> </div>
<div>comments = [c for c in all_comments if c.rating > 2]</div>
<div><br> </div>
<div><span style="WHITE-SPACE: pre"></span>You can cache *that* as well if you do find it to be expensive to recreate. Then you just need to clear potentially cached filtrations when updating comments or comment lists.</div>
<div><br> </div>
<div><span style="WHITE-SPACE: pre"></span>Using the above, I'd expect you to be able to have excellent cache accuracy and really good performance.</div></div></blockquote>
<div> </div>
<div>Currently I only store the vote score in the comment itself. You are saying I should store it in the comments listing too? </div>
<div> </div>
<div>I might give that a try, and do the comment filtering in the php app instead.</div>
<div><br>There are some other examples though, where it gets really expensive to re-calculate on every change. For instance search results. If just one item's attributes change (which happens probably once every 10 seconds), a whole range of search queries would be invalided.
</div>
<div> </div>
<div>Take for example, Myspace's browse page. There are multiple options you can select, such as age, zip code, sex, etc. Just having one user change his zip code would invalidate all the combinations that involve the zip code. If the site is busy, invalidations could be occurring every few seconds, putting lots of load on the server. Then, at night when there's little traffic, hardly any updates are happening.
</div>
<div> </div>
<div>Would this type of situation warrant what I was suggesting?</div>