[Dbix-class] Caching a resultset?

Jesse Sheidlower jester at panix.com
Tue Jan 15 15:12:37 GMT 2013


On Tue, Jan 15, 2013 at 02:15:02PM +0000, David Cantrell wrote:
> On Sun, Jan 13, 2013 at 11:35:06PM -0500, Jesse Sheidlower wrote:
> 
> > I have a Catalyst app that very frequently (pretty much every request)
> > requires several DBIC resultsets that return a small number of values,
> > that very rarely change. I'm trying to cache this, so I can update the
> > cache when the values change and not have to hit my DB a half-dozen
> > times on every request for data that is effectively static.
> 
> To solve this problem at the BBC in the guts of iPlayer, we used
> memcache.  We *didn't* bother updating the cache if the DB contents
> changed though, as we didn't mind the user's view being a few minutes
> out of date.

While it wouldn't matter much if things were a little out of date, my
site is relatively low traffic, so caching something for a few minutes
wouldn't make much difference. So I need to cache it long-term, and I do
need to update on a change.

> I've spent quite a bit of time thinking about how to solve this in the
> general case, and not come up with anything that works yet - not even
> anything that works in theory and goes arse-over-tit in practice.
> 
> Can you at least reduce it to one query with a left right in out shake
> it all about join?

Not really. The problem is that I have a number of separate, unrelated
tables, each having "category"-like data (category, status, region,
other-status, etc.), and each being used in different ways, so I have to
get each table separately.



More information about the DBIx-Class mailing list