Re[2]: MySQL Techniques

by Nathan Lyle <nathan(at)upwebmaestro.com>

 Date:  Sat, 11 Jan 2003 01:32:27 -0500
 To:  Hank Marquardt <hmarq(at)yerpso.net>
 Cc:  hwg-techniques <hwg-techniques(at)hwg.org>
 References:  upwebmaestro yerpso upwebmaestro2 yerpso2
  todo: View Thread, Original
<Hank>
> What I'm speaking of would be in php ... basically whenever you run a
> query, you store the results in a file on the server with some unique
> filename (I use md5(Querystring)) ... then as part of your query process
> (either a function or part of your database object), you first test for
> the presense of a file with an md5() value of your query string, if you
> find one, check the timestamp on the file .. if the file is current,
> just return the contents of the file (serialize(), gzcompress() are
> handy here), ortherwise execute the query (*and* store the results in
> the cache in addition to returning them).

Ahh... I just sent a question this answered a few minutes ago. Sorry
about that. Does file read/write time become as much an issue as
waiting on a query? (From your experience?)

> I realize that's a mouthful.   If you're interested in doing that, do a
> google on "mysql cache php" ... if that turns up nothing useful, email
> me and I'll send you the code I use (a generic cache class, and a mysql
> class that takes advantage of the cache)

I would certainly be interested in peeking at your code, so feel free
to send it to me (offlist I assume). I'll do some searching myself and
some experimenting and see if this might be the direction to go...

> As for your application ... look at your own example, if someone enters
> "Love" as a search term you're going to get hundreds (if not thousands)
> of results back ... you've got to page them, in that case, when someone
> clicks previous/next, they won't talk to the database, just the cache
> ... that speeds things up tremendously and frees up the connection pool
> to the database to handle more traffic.

The only thing I worry about here is whether reading to/from files
would become the new bottleneck. But, I haven't tried it yet, so can't
really know until I do. :)

~ Nathan Lyle
   __  __   ____   _       __     __      __  ___                __           
  / / / /  / __ \ | |     / /__  / /_    /  |/  /___ ____  _____/ /__________ 
 / / / /  / /_/ / | | /| / / _ \/ __ \  / /|_/ / __ `/ _ \/ ___/ __/ ___/ __ \
/ /_/ /_ / ____/  | |/ |/ /  __/ /_/ / / /  / / /_/ /  __(__  ) /_/ /  / /_/ /
\____/(_)_/ (_)   |__/|__/\___/_.___/ /_/  /_/\__,_/\___/____/\__/_/   \____/ 

     www.upwebmaestro.com     nathan(at)upwebmaestro.com     (906)485-4806

"Where a calculator on the ENIAC is equipped with 18,000 vacuum 
 tubes and weighs 30 tons, computers of the future may have only 
 1,000 vacuum tubes and perhaps weigh 1.5 tons." - Popular Mechanics, March 1949.

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA