dustin at spy.net
Sat Sep 29 18:41:26 UTC 2007
On Sep 29, 2007, at 0:43, K J wrote:
> For instance, suppose I have voting for comments, and users can
> filter by votes (like digg/youtube/slashdot). I set a memcache
> list for every filter. However when there are changes to a
> particular comment's vote score, the list would be invalidated.
> Imagine if there is a lot of voting going on, it would mean the
> filter lists are constantly being reloaded by the database?
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.
After that, your filter op can happen on the client:
comments = [c for c in all_comments if c.rating > 2]
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.
Using the above, I'd expect you to be able to have excellent cache
accuracy and really good performance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the memcached