Caching collections of objects
Peter Van Dijck
petervandijck at gmail.com
Sun May 27 07:20:26 UTC 2007
I'd love to hear thoughts on this as well, since I struggle with the
On 5/26/07, Mike Marrone <mike.marrone at cambrianhouse.com> wrote:
> I have recently been looking into integrating memcache into our apps,
> and had a few newbish implementation questions...
> (please forgive me for any ignorance I may have towards memcache, I am
> still new to it!)
> Memcache is great for retrieving/updating single objects from the cache.
> Obviously where the biggest gains are going to come from though are with
> searches and caching of collections of objects. I am debating over two
> approaches here:
> 1. Caching of collections (eg: "give me all the user comments related to
> 2. Caching entire page outputs based upon the unique url (eg: "give me
> the xhtml output for foo/bar?baz=1")
> 3. A combination of #1 & #2
> Getting the data into the cache and retrieving it when appropriate is a
> simple matter. It is when the data in the cache has become stale and I
> need to flush it from the cache that I become stuck as to how best to
> solve the problem.
> Take for example a news article. It may have a user comments, a view
> count, user votes, etc. Furthermore the news article may appear in lists
> on separate pages under the author's profile, or in a search, etc. When
> it becomes stale, I would need to either flush all cached collections
> containing that object, or flush all cached page data where that object
> One solution for approach #2 above is to simply flush all cached page
> data whenever there are writes to the database. Though this is
> sub-optimal and would result in low cache hit rates I'm assuming.
> I'm sure others out there have solved this problem already. Would anyone
> mind sharing their thoughts with me?
> Thanks in advance
> Mike M
US: (+1) 201 467-5511
Belgium: (+32) 03/325 88 70
Skype id: peterkevandijck
More information about the memcached