[nycphp-talk] PEAR DB_Cache question
David Mintz
dmintz at davidmintz.org
Tue Dec 2 16:40:17 EST 2003
On Tue, 2 Dec 2003, Adam Maccabee Trachtenberg wrote:
> On Tue, 2 Dec 2003, David Mintz wrote:
>
> > I've been studying the recipe in the Cookbook, which is the closest thing
> > to documentation that I've been able to find for DB_Cache, other than in
> > the source.
>
> I've often found that PHP Cookbook is the only documention for PEAR
> packages. Of course, it means when people ask me questions about the
> recipes, I'm forced to re-read to source to rememeber why I wrote what
> I did. Even worse, Dave wrote that recipe. :)
Ha! Speaking of which, in case you're considering coming out with another
edition someday, a suggestion/question: wouldn't you want to use
$db->setConnection($dsn) in this recipe, which "[registers] a database
connection for connect on demand"? I can't understand why anyone would
want to use the unconditional connect() when they're only planning to
SELECT, if the whole point is to save db overhead. (Then again I've hardly
mastered the internals ergo don't know what I'm talking about (-: )
>
> > <snip />If you just say flush('db_cache') then you flush the cached
> > results of ~both~ queries.
>
>
> Right. I believe the assumption is that you want to flush the cache
> when you update your data and that all datasets have similar update windows.
>
>
> > The more general problem is that my application relies on some MySQL
> > tables that get updated many times a day, and some tables that get updated
> > a few times a year. Hence my interest in DB_Cache.
>
> Can't you set up two caches? One for the frequently updated data and
> one for the few times a year updated data? Or only cache the few times
> a year data and don't bother caching the frequently updated data at
> all?
>
Yes, certainly. I plan not to cache the frequently-updated at all, and
cache the quasi-static, but I guess I was trying to tune the caching more
finely than this class thinks I need to. So it seems the answer is, blow
away the whole cache when you flush(), and don't worry about it, you're
still realizing big big savings.
Thanks again Adam. Love that book! Now back to the kitchen.
---
David Mintz
http://davidmintz.org/
ATTN Everybody: dmintz at panix.com will be unplugged as of 01-Dec-2003!
Please use dmintz at davidmintz.org
"Anybody else got a problem with Webistics?"
Sopranos 24:17
More information about the talk
mailing list