NYCPHP Meetup

NYPHP.org

[nycphp-talk] PEAR DB_Cache question

David Mintz dmintz at davidmintz.org
Tue Dec 2 15:40:29 EST 2003


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.

So here's what I don't understand. Say you're using the 'file' container
-- a disk-based cache. When you call the constructor like so

$db = new Cache_DB('file',array('cache_dir'=>'/my/cache_dir/'),86400);


you're telling it where to cache data. Fine. Then you do a query -- call
it query_1. Suppose in the course of the same script you want to cache the
results of another query_2. Further suppose that at some point you want to
be able to flush() the cached results of query_1, but not query_2. If you
just say flush('db_cache') then you flush the cached results of ~both~
queries.

Are we supposed to set cache_dir to different values for each query before
querying and/or calling flush? I haven't found any setter method for doing
that, and although I realize that in PHP 4 you can can access object
variables directly, I wonder if code written that way might break in PHP
5.

I guess you could also create a new Cache_DB instance with different
arguments for each query, but that seems wasteful.

I hope this is coherent -- if I sound confused it's because I am confused.
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.

Many TIA,


---
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