Module for caching database requests
| From: | ekke at chamber dot ee | Date: | Tue, 26 Jun 2001 15:58:03 +0000 |
| Subject: | Module for caching database requests | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-492@lists.php.net to get a copy of this message | ||
Hi pearists,
I was just wondering why there isn't a pear module that would cache
DB requests.
Is someone developing it and it's well very well-hidden or is it not
necessery at all?
Anyway, if noone has anything better coming up, one nice day when i get
myself
to finish documenting my cache_db module and add error reporting i'll
put some
experimental version to cvs. Right now it already has most of the
features implemented..
How it works?
For storing results i wrote a class DB_fakeResult that stores results of
queries (taken
from cache) in a two-dimensional array and operates fetchRow() and
fetchInto()
on that.. Only thing not working is tableInfo() function..
the Cache_DB i have is meant to work rather invisibly:
$dbz = DB::Connect ($dsn);
$db = new Cache_DB ($dbz);
$res = $db->query($q);
$row = $res->fetchRow();
.. and to try it without the cache you can just replace
$db = new Cache_DB ($dbz);
with
$db = &$dbz;
or just say
$db->setCaching(0);
ugh.. if smb want's to test out i put up the modules to
http://www.chamber.ee/ekke/cachedb.tgz
two files in there then, Cache/DB.php and DB/fakeResult.php
oh, and i've only tested Cache_DB with file cache so far and it's
hardcoded into the module right now, gotta change that too..
ok then, i'll be waiting for comments..
--
ekke
+3725058839
The future lies ahead.